Hi Erik,

> "$phone" is a 10-digit string.
> I would like the output to be
> $phone = "(555) 555-5555";

you don't need regex to do that.
just insert add "(" to the beginning of $phone,
add ") " to the 4th position,
and "-" to the 4th position from behind,
using substr_replace() function.

anyway if you insist on using regex:
preg_replace("/(\d{3})(\d{3})(\d{4})/", "(\\1) \\2-\\3", $arr);

--
Jimmy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Everything loses its value when overly used, including love.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to