Remove non alphabet, non-numbers (alphanumeric) from string - PHP Views : 928
Tagged in : PHP
0 0
Send mail
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..
By rajesh, On - 2010-01-03



    Login to add Comments .