Re: [PHP] variable type - conversion/checking
[email protected] (richard gray)
| Newsgroups | php.general |
|---|---|
| Message-ID | <[email protected]> |
On 15/03/2013 22:00, Ashley Sheridan wrote:
> On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote:
>
>
> For my money, `is_numeric()` does just what I want.
>
>
> The thing is, is_numeric() will not check if a string is a valid int,
> but any valid number, including a float.
>
> For something like this, wouldn't a regex be better?
>
> if(preg_match('/^\-?\d+$/', $string))
> echo int
>
I'm late in on this thread so apologies if I have missed something here
.. but wouldn't is_int() do what the OP wants?
rich