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?
$formatted_number = preg_replace('/^([0-9]{3})/,'\1-',$number);
-- ---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php