Re: Formatting phone numbers?

From: Date: Fri, 16 Apr 2004 14:07:15 +0000
Subject: Re: Formatting phone numbers?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-183625@lists.php.net to get a copy of this message
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-xxxx > >>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 number, though, not insert the dash? No, it does the right thing. The last 0 is the number of characters to replace. - Rob

« previous php.general (#183625) next »