RE: [PHP] Formatting phone numbers?

2004-04-17 Thread Andy Crain
Jay, > Here is a little more of the larger function with comments (more > comments than code, which is never a Bad Thing [tm]). I am only showing > the handling for two basic types of telephone numbers with explanation > for additional verification which we would typically use, since we have > tho

RE: [PHP] Formatting phone numbers?

2004-04-16 Thread Jay Blanchard
[snip] > [stuff you may not need] > This is a boiled down version of a longer function that counts string > lengths to determine how many dashes might need to be added. Let's say > you have the area code in the number, like 2108765432. Being a ten digit > number with a recognizable area code we can

RE: [PHP] Formatting phone numbers?

2004-04-16 Thread Andy Crain
Good stuff. > [stuff you may not need] > This is a boiled down version of a longer function that counts string > lengths to determine how many dashes might need to be added. Let's say > you have the area code in the number, like 2108765432. Being a ten digit > number with a recognizable area code

RE: [PHP] Formatting phone numbers?

2004-04-16 Thread Paul Fine
Thanks! -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: April 16, 2004 7:33 AM To: BOOT; [EMAIL PROTECTED] Subject: RE: [PHP] Formatting phone numbers? [snip] Thanks for any help, even if you just suggest built in functions to look at. I'm looking for a w

Re: [PHP] Formatting phone numbers?

2004-04-16 Thread Rob Ellis
On Thu, Apr 15, 2004 at 06:11:57PM -0400, John W. Holmes wrote: > Rob Ellis wrote: > >On Thu, Apr 15, 2004 at 04:31:09PM -0500, BOOT wrote: > >> > >>I'm looking for a way to take a 7 digit number and put it into xxx- > >>format. > >> > >>So basically the logic is to count 3 characters into $num

RE: [PHP] Formatting phone numbers?

2004-04-16 Thread Jay Blanchard
[snip] Thanks for any help, even if you just suggest built in functions to look at. I'm looking for a way to take a 7 digit number and put it into xxx- format. So basically the logic is to count 3 characters into $number and insert a "-" there. [/snip] As a telecom we use several methods, bu

Re: [PHP] Formatting phone numbers?

2004-04-15 Thread John W. Holmes
Rob Ellis wrote: On Thu, Apr 15, 2004 at 04:31:09PM -0500, BOOT wrote: >> I'm looking for a way to take a 7 digit number and put it into xxx- format. So basically the logic is to count 3 characters into $number and insert a "-" there. substr_replace($string, '-', 3, 0); Won't that replace the n

Re: [PHP] Formatting phone numbers?

2004-04-15 Thread Rob Ellis
On Thu, Apr 15, 2004 at 04:31:09PM -0500, BOOT wrote: > Thanks for any help, even if you just suggest built in functions to look at. > > I'm looking for a way to take a 7 digit number and put it into xxx- > format. > > So basically the logic is to count 3 characters into $number and insert a

Re: [PHP] Formatting phone numbers

2002-06-23 Thread Chris Shiflett
Corinne Shea wrote: >Hi, > >I'd like to write a function that will take a string of characters and >output it in a phone number format (xxx)xxx- and one for credit >cards ---. > This is actually very easy to do if all you want to do is format, meaning you have already valid

Re: [PHP] Formatting phone numbers

2002-06-23 Thread Paul Roberts
preg_replace will do it. $returnValue = preg_replace("/(\d{3})(\d{3})(\d{4})/","($1)$2-$3",$returnValue); (\d{3})(\d{3})(\d{4}) = $0 or \\0 we aren't using this match we are using the subpatterns in brackets (\d{3}) =$1 or \\1 matches 3 numbers (\d{3}) =$2 or \\2 matches 3 numbers (\d{4}) =$3 o