There is a simple way to remove non-ascii characters from a string. This can be used to filter values from POST variables as well. Following line of code does the thing.
$string = "This is a test É";
//replace the non-ascii characters from string with nothing i.e. remove
preg_replace('/[^(\x20-\x7F]*/','',$string);
echo $string;
No comments:
Post a Comment