I think this is along the lines of what you are looking for.
I'm a bit rusty on the sprintf function, so that part might need tweeking.
$string represents the string you want to make into a number, and $decimal specifies how many decimal places it should have.
<?php
function toNumber ($string, $decimal = 0) {
$decimal = (int)$decimal;
if (!is_numeric($string))
return 0;
$formatted = sprintf('%01.'.$decimal.'f', $string);
if ($decimal > 0)
return (double)$formatted;
else
return (int)$formatted;
}
?>
Altough, this might be easier:
$variable = (double)$_GET['arg'];
EDIT
I misread the first post.
You need to regex your string for numeric values