Top

Strip non-ASCII characters from a String


PHP Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Mar 31, 2008
Last Updated  Mar 31, 2008
Tags  ascii  pregreplace  strip 

Introduction

This is a little snippet that will remove any non-ASCII characters from a string.

Grab the Code

<?php
 
$string = "Remove these characters: รครณ";
$string = preg_replace('/[^(\x20-\x7F)]*/','', $string);
 
?>

Comments

  (0)  RSS

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom