Re: including parenthesis, space and dashes in a phone number

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

 



Warren Vail wrote:
> Not to mention that syntax works in the US, but not large portions of the
> rest of the world.  (even with the 1 country code in front).

can't remember when that ever stopped an american.

e.g. Windows print subsystem that shoves 'Letter' format down
your throat as the default even though the OS knows damn well I'm
using a european locale.

> 
> Warren vail
> 
>> -----Original Message-----
>> From: afan pasalic [mailto:afan@xxxxxxxx]
>> Sent: Friday, November 30, 2007 12:03 PM
>> To: Daevid Vincent
>> Cc: 'php-general'
>> Subject: Re:  including parenthesis, space and dashes in a phone
>> number
>>
>> It's ok to store it this way, but it could be a little PITA when search.
>> E.g., you store (123) 456-7890 and somebody search for 123-456-7890?
>> Right?
>>
>> -afan
>>
>>
>>
>> Daevid Vincent wrote:
>>> The kind of opposite of this, is what I use, in that it ADDs the () and
>> -
>>> if ((strlen($phone)) <= 14) $phone =
>>> preg_replace("/[^0-9]*([0-9]{3})[^0-9]*([0-9]{3})[^0-9]*([0-9]{4}).*/",
>>> 		  "(\\1) \\2-\\3", $phone);
>>>
>>>> -----Original Message-----
>>>> From: afan pasalic [mailto:afan@xxxxxxxx]
>>>> Sent: Friday, November 30, 2007 5:45 AM
>>>> To: php-general
>>>> Subject:  excluding parenthesis, space and dashes from
>>>> phone number
>>>>
>>>> hi,
>>>> I store phone number in mysql as integer, e.g. (123) 456-7890
>>>> is stored
>>>> as 1234567890.
>>>> though, in search form they usually type in a phone number with
>>>> parenthesis/space/dashes. I have to extract numbers before I search
>>>> through mysql.
>>>>
>>>> currently, I use eregi_replace() function, several times, to
>>>> do the job:
>>>> eregi_replace(' ', '', $phone);
>>>> eregi_replace('(', '', $phone);
>>>> eregi_replace(')', '', $phone);
>>>> eregi_replace('-', '', $phone);
>>>> and it works fine.
>>>>
>>>> but, is there any better way? more "fancy"? :)
>>>>
>>>> thanks for any help.
>>>>
>>>> -afan
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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