Re: Checking Phone Numbers

From: Date: Thu, 14 Jun 2007 15:45:20 +0000
Subject: Re: Checking Phone Numbers
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-257004@lists.php.net to get a copy of this message
On Thu, 2007-06-14 at 08:38 -0700, Kevin Murphy wrote: > I collect phone numbers via a web form that breaks the phone number > up into 3 parts (3-digit area, 3-digit prefix, etc). Occasionally, I > am having people put in a phone number such as 999-999-9999 or > 000-000-0000 or other numbers that are all the same. How would I go > about comparing those three fields to see if they are all the same > numbers. I can't just exclude it anytime that the numbers all match, > for example 444 is a valid area code. It should only fail if all the > numbers are exactly the same. > > All the processes I've come up with seem to be rather convoluted. Is > there a simple way to test for this? <?php $number = $field1.$field2.$field3; $digit = (int)substr( $number, 0, 1 ); if( ereg( '^'.$digit.'+$', $number ) ) { echo 'All the same :/'; } ?> Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.general (#257004) next »