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 100000 iterations, and the regexp was nearly 2 times slower than the first solution. IMHO, it's also faster to read and modify the first solution too -- especially for those with minimal regexp experience.



Justin



On Wednesday, July 16, 2003, at 11:07 PM, 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://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to