Detecting whether number string or operator/letter string in PHP?

Posted by chimerical on Stack Overflow See other posts from Stack Overflow or by chimerical
Published on 2010-06-06T00:20:37Z Indexed on 2010/06/06 0:22 UTC
Read the original article Hit count: 525

Filed under:

In PHP, how do I distinguish between a number as a string [0-9] versus an operator (+-*/) or letter [A-Za-z]?

I tried this, but intval also converts the type of nonnumbers to ints as well:

is_int(intval($somestr));

Is regex the way to do it?

© Stack Overflow or respective owner

Related posts about php