Curt,
yes, technically, 0 is a number - it's a bit late here, and I believe I
mis-understood the original question, which is why I re-posted in the thread.
I guess my mind got a bit confused by the combination of "is_int doesn't
work", "intval returns a number" and "'10' vs 'ten'" example.
If I misunderstood the intval part of your post, than the [proposed already]
is_numeric solutions are the way to go. is_numeric will, however, unlike the
conversion functions, return false if there's anything but a number in the
string, so, i.e., is_numeric ("10a1") will return false, but intv
Which version of PHP are you using? On php 4.4.0 (SuSE 10.0 default RPM, not
custom build, so perhaps I'm missing some extras you're using?) the following
script works fine:
I get no boo. intval doesn't convert my "ten" to a number. Moreover, the
output of the following:
produces an e
On Thu, Nov 17, 2005 at 02:37:49PM -0500, blackwater dev wrote:
> How can I check to see if a string var holds a number? Is regex the
> only way to do this? For example I have code where the var could hold
> "10" or "ten". If the string is a number, do one thing, if it isn't
> do something else.
How can I check to see if a string var holds a number? Is regex the
only way to do this? For example I have code where the var could hold
"10" or "ten". If the string is a number, do one thing, if it isn't
do something else. is_int doesn't work, intval converts "ten" to a
number so that doesn't
5 matches
Mail list logo