Re: Checking Phone Numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.          |
`------------------------------------------------------------'

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux