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");
This function should only return numbers from a string. Is this function encoded correctly?
source
share