Strip non-ASCII characters from a String

By Hawkee on 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!

More
 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.