I want to make sure the input is A)a number and B)has at most 2 decimals.
$number[$i]=int(100*$number[$i])/100;
I imagine there is a more efficient way to do this... any suggestions? (using PHP).
views:
24answers:
3I just looked at the man (http://php.net/manual/en/function.number-format.php) ... I assume the `, '')` at the end is to keep the commas in the thousands places from showing up?
aslum
2010-04-05 19:10:14
yes, that's correct.
GSto
2010-04-05 20:51:26
+1
A:
Regexes to the rescue:
if (preg_match('/^\d+\.\d{2}$/', $number[$i])) {
etc...
}
of course, now that regexes are involved, you've got two problems, as the old saying goes.
Marc B
2010-04-05 19:08:43