Re: [PHP] Verifying a certain amount of numbers

2003-07-16 Thread Justin French
On Thursday, July 17, 2003, at 12:17 AM, Curt Zirzow wrote: Excellent point! I find my self using regex's a bit to often when there are other solutions available. btw, have you ever tested the difference between if(ereg('^[0-9]{6}$',$str)) if(preg_grep('^[0-9]{6}$',$str)) I've be

Re: [PHP] Verifying a certain amount of numbers

2003-07-16 Thread Curt Zirzow
Justin French <[EMAIL PROTECTED]> wrote: > If you care about performance at all, try and find away around the > problem without regular expressions... > > I tested > > if( (strlen($str) == 6) && (is_int($str)) ) > I did some more tests on this problem is that $str is still considered a st

Re: [PHP] Verifying a certain amount of numbers

2003-07-16 Thread John Manko
Yes, use preg_match("/^[0-9]{6}$/",$str) since it takes care of both number and length. You dont want to you is_numeric(), because that will match "4e5", etc..etc.. Brent Baisley wrote: I'm pretty sure there will be a problem with using the is_int() function. A similar problem was discussed a f

Re: [PHP] Verifying a certain amount of numbers

2003-07-16 Thread Curt Zirzow
Ford, Mike [LSS] <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: Curt Zirzow [mailto:[EMAIL PROTECTED] > > Sent: 16 July 2003 15:17 > > > > Justin French <[EMAIL PROTECTED]> wrote: > > > If you care about performance at all, try and find away around the > > > pro

Re: [PHP] Verifying a certain amount of numbers

2003-07-16 Thread Curt Zirzow
Brent Baisley <[EMAIL PROTECTED]> wrote: > I'm pretty sure there will be a problem with using the is_int() > function. A similar problem was discussed a few weeks ago on this list > and is_int() will return true for a "number" like 1000e2. The "e" being > treated as an exponential representation

Re: [PHP] Verifying a certain amount of numbers

2003-07-16 Thread Brent Baisley
I'm pretty sure there will be a problem with using the is_int() function. A similar problem was discussed a few weeks ago on this list and is_int() will return true for a "number" like 1000e2. The "e" being treated as an exponential representation of an integer. It might be more reliable to add

RE: [PHP] Verifying a certain amount of numbers

2003-07-16 Thread Ford, Mike [LSS]
> -Original Message- > From: Curt Zirzow [mailto:[EMAIL PROTECTED] > Sent: 16 July 2003 15:17 > > Justin French <[EMAIL PROTECTED]> wrote: > > If you care about performance at all, try and find away around the > > problem without regular expressions... > > > > I tested > > > > if( (

Re: [PHP] Verifying a certain amount of numbers

2003-07-16 Thread Ivo Fokkema
"Curt Zirzow" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Excellent point! I find my self using regex's a bit to often when there > are other solutions available. > > btw, have you ever tested the difference between > > if(ereg('^[0-9]{6}$',$str)) > if(preg_grep('^[0-9]{6}$',$st

Re: [PHP] Verifying a certain amount of numbers

2003-07-16 Thread Curt Zirzow
Justin French <[EMAIL PROTECTED]> wrote: > If you care about performance at all, try and find away around the > problem without regular expressions... > > I tested > > if( (strlen($str) == 6) && (is_int($str)) ) > > vs > > if(ereg('^[0-9]{6}$',$str)) > > > ...on my LAN test serve

Re: [PHP] Verifying a certain amount of numbers

2003-07-16 Thread Justin French
If you care about performance at all, try and find away around the problem without regular expressions... I tested if( (strlen($str) == 6) && (is_int($str)) ) vs if(ereg('^[0-9]{6}$',$str)) ...on my LAN test server with 10 iterations, and the regexp was nearly 2 times slower than the f

Re: [PHP] Verifying a certain amount of numbers

2003-07-16 Thread Marek Kilimajer
if(!ereg('^[0-9]{6}$',$string) die('not six numbers'); you might want to trim off white space first. Ron Allen wrote: I would like to know how to verify that there are 6 numbers (only numbers in a field) that will be submitted to a database? Any clues! -- PHP General Mailing List (http://ww

[PHP] Verifying a certain amount of numbers

2003-07-16 Thread Ron Allen
I would like to know how to verify that there are 6 numbers (only numbers in a field) that will be submitted to a database? Any clues! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php