Hi,

Sunday, April 25, 2004, 11:17:16 AM, you wrote:
AB> hi...

AB> i have a string i want to pull out of a database (mysql). the column name is
AB> Phone1 and it is a 10 digit phone number. the raw string coming out of the
AB> table column would look like this: 1234567890

AB> what i want to do is format the string on display like this: (123)456-7890
AB> but dont quite know how to start with that. what function(s) would i use for
AB> that?


Try this:
$phone = '1234567890';
$newphone = preg_replace('/(\d{3})(\d{3})(\d)/','(\1)\2-\3',$phone);
echo $newphone.'<br>';

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to