Re: How to find if a string is an integer?

From: Date: Thu, 12 Jun 2003 01:37:58 +0000
Subject: Re: How to find if a string is an integer?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-151176@lists.php.net to get a copy of this message
It's not that killing... :p preg_match("#^-?[0-9]+$#",$_POST["var_int"]); I was also thinking about that === operator.. And this: if(((string)((int)$_POST["var_int"]))==$_POST["var_int"]) "Jean-Christian Imbeault" <jc@mega-bucks.co.jp> skrev i meddelandet news:3EE7CFC8.20600@mega-bucks.co.jp... > Felipe Desiderati wrote: > > try this: > > > > if (ereg("^[0-9]+$", $_POST["var_int")) > > echo "is int"; > > That's not the best regexp. It doesn' take into account negative > integers and isn't there a [[:numeric:]] or something like regexp that > would work better. > > I'm looking for the simplest method and the one that takes the less > processing power :) > > Calling up the regular expression engine dounds pretty processing > intensive ... >

« previous php.general (#151176) next »