Strip non-ASCII characters from a String

Platform:  PHP
Published  Mar 31, 2008
Updated  Mar 31, 2008
This is a little snippet that will remove any non-ASCII characters from a string. <?php

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

?>

Comments

Sign in to comment.
psy   -  May 03, 2012
Legend!!! wooop!
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.