Re: [PHP] checkng if string is a number

2005-11-17 Thread Max Belushkin
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.

Re: [PHP] checkng if string is a number

2005-11-17 Thread Max Belushkin
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

Re: [PHP] checkng if string is a number

2005-11-17 Thread Max Belushkin
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

Re: [PHP] checkng if string is a number

2005-11-17 Thread Curt Zirzow
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.

[PHP] checkng if string is a number

2005-11-17 Thread blackwater dev
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