-replace multiple white space with a space
$foo = preg_replace( '/\s+/', ' ', $foo );
-extract numbers from a string
$string = "The 1. Quick and 2. Brown fox said 3. (!@*(#!@*";
$new_string = ereg_replace("[^0-9]", "", $string);
echo $new_string; #123
Related posts: