Re: [PHP] Number checker

2002-04-18 Thread Philip Olson

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




Re: [PHP] Number checker

2002-04-18 Thread Robert Cummings

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...
> 
> return ereg( '^[[:alpha:]]*$', $testString );

I should kick myself...

return ereg( '^[[:digit:]]*$', $testString );

Cheers,
Rob.
-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Number checker

2002-04-18 Thread Robert Cummings

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 );

Cheers,
Rob.
-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Number checker

2002-04-18 Thread Erik Price


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);






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php