Re: Re: Phone Number #s Only?

From: Date: Fri, 03 Aug 2001 14:34:22 +0000
Subject: Re: Re: Phone Number #s Only?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-61133@lists.php.net to get a copy of this message
on 8/2/01 9:55 PM, Richard Lynch at ceo@l-i-e.com wrote: > While the solution given will work, consider the following perfectly valid > phone numbers: > > 312-555-1234x1001 > 1-800-MY-STUFF > > Also, once you strip out all the spaces and dashes, nobody but a computer > can use it... > > Do you *really* want to make it difficult for humans to use? good point richard. i never really considered the 1-800-MY-STUFF case. most of my customers seem to want numbers only.. anyway, assuming numbers only and no extensions (you can change this to add extensions pretty easily)... in a form where i want a phone number, i have 3 separate fields of length 3,3,4 respectively. when the form is submitted, i check to make sure there are only numbers. (actually, on some sites i use javascript to check this as well) i have two functions--phone_from_3() and phone_to_3(). i use phone_from_3() to set $phone = $phone1 . $phone2 . $phone3. i then put $phone in the db. when i want to display the phone number somewhere, i use phone_to_3() to turn $phone into $phone1, $phone2, $phone3. i can then format the phone number making it easy to read. hope this helps, mike -- mike cullerton

« previous php.general (#61133) next »