Remove non alphabet, non-numbers (alphanumeric) from string
by rajesh[ Edit ] 2010-01-03 15:01:06
Remove non alphabet, non-numbers (alphanumeric) from string (leaving white space)
Again ereg_replace will come to our help...
ereg_replace("[^A-Za-z0-9\s]", "", $string_to_be_stripped );
Example
$string_to_be_stripped = "NON alpha & numeric # string replace";
$new_string = ereg_replace("[^A-Za-z0-9\s]", "", $string_to_be_stripped );
echo $new_string;
?>
Result: "NON alpha numeric string replace";
if we don't want space too then we have to use [^A-Za-z0-9] instead of [^A-Za-z0-9\s] in ereg_replace..