i want to check if a given string has only numbers
for exampl
$test = "343124312" TRUE
$test1 = "q34daf23423" FALSE
Jeoren
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
On Thursday, April 18, 2002, at 02:58 PM, Jeroen Timmers wrote:
> i want to check if a given string has only numbers
>
> for exampl
>
> $test = "343124312" TRUE
> $test1 = "q34daf23423" FALSE
use either is_numeric(), or for whole numbers only, use a regex:
preg_match('/^\d+$/', $test);
--
Jeroen Timmers wrote:
>
> i want to check if a given string has only numbers
>
> for exampl
>
> $test = "343124312" TRUE
> $test1 = "q34daf23423" FALSE
I'm tempted to say "go read about ereg(), but since it's
just as long to provide a response...
return ereg( '^[[:alpha:]]*$', $testString );
Robert Cummings wrote:
>
> Jeroen Timmers wrote:
> >
> > i want to check if a given string has only numbers
> >
> > for exampl
> >
> > $test = "343124312" TRUE
> > $test1 = "q34daf23423" FALSE
>
> I'm tempted to say "go read about ereg(), but since it's
> just as long to provide a response...
>
use is_numeric()
http://uk.php.net/is_numeric
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
5 matches
Mail list logo