well, if all numbers are *always* 10 digits long,
use this
$old = "1234567890";
$new = preg_match('/(\d{3})(\d{3})(\d{4})/', $old, $matches);
print "(". $matches[1] .") ". $matches[2] ."-". $matches[3];
prints "(123) 456-7890"
> -----Original Message-----
> From: Jerry Lake [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 15, 2001 6:48 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] again with the regex
>
>
> I hate to keep asking regex stuff,
> but it is really evasive for me..
> I'm pulling phone numbers out of a DB
> in the format of 1234567890, I would
> like to format them like (123) 456-7890
> or something else that at least breaks them
> up a bit.
>
> any help is appreciated,
> Thanks,
>
> Jerry Lake
> Interface Engineering Technician
> Europa Communications - http://www.europa.com
> Pacifier Online - http://www.pacifier.com
>
>
> --
> 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]
>
--
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]