Wondering if there is a way to determine if a given variable is a valid number, e.g.
$var = "1234" // valid $var = "123G" // not valid
Is there a function which can do this.
is_numeric() its in the manual...
-paul
if(ereg("[0-9]{1,}$",$var)) { ... } else { ... }
Just wanted to add that I believe all variables received from a form are input as string types so if you use a function like is_numeric it may not work as intended. 🙂
John
Well, in PHP there aren't really set types, so I'll bet it would work. Also, though, you could do this:
if(!eregi("[0-9]",$var)) { //it is numeric }