function get_only_numbers($string){
$getonly = str_split("0123456789");
$string = str_split($string);
foreach($string as $i => $c){
if(!in_array($c, $getonly))
unset($string[$i]);
}
return implode("", $string);
}
echo get_only_numbers("U$ 499,50"); // prints 49950
This function is supposed to return only the numbers from a string.
Has this function been coded properly?
I think a single call to preg_replace can do that as well: