Re: [PHP] Reformatting phone number string from user input

This is a discussion on Re: [PHP] Reformatting phone number string from user input within the PHP General forums, part of the PHP Programming Forums category; Yes, I found some examples in the archives that measured a clean string and formatted it according to whether it ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-10-2003
Verdon Vaillancourt
 
Posts: n/a
Default Re: [PHP] Reformatting phone number string from user input

Yes,

I found some examples in the archives that measured a clean string and
formatted it according to whether it found 4 (is an error), 7 (xxx-xxxx), 10
(xxx-xxx-xxxx) or 11 (x-xxx-xxx-xxxx). I'm going to work with this sort of
logic and standardize the format (or maybe just the length of string) before
inserting into my db. I haven't completely decided if it's better to store
1234567890 and format it on retrieval or to format it first and store
123-456-7890. I guess unless I plan to do math or something with the raw
data later (not too likely for a phone number), it probably doesn't make
much difference.

Thanks again :)


On 8/10/03 2:25 PM, "John W. Holmes" <holmes072000@charter.net> wrote:

> After you replace all of the non numeric characters, if the length is 7,
> you can add the default area code.


> Verdon vaillancourt wrote:
>
>> Thanks John,
>>
>> That does look a lot tidier. I tried a similar approach early on, but was
>> trying to specifically match '(' and ')' and was running into lots of
>> trouble with my syntax, in specific, properly escaping \( and \) so they
>> were not treated as paranthesis/operators/whatever. This is much simpler. I
>> like simple :)
>>
>> Now I can focus on inserting a default area code, if the user does not ;)

>


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:36 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0