PROTECTED]
Subject: RE: [PHP] again with the regex
Jerry, try sprintf(). Here's an example:
sprintf("(%s) %s-%s", substr($GLOBALS["appPhoneHome"], 0,
3),substr($GLOBALS["appPhoneHome"], 3, 3),substr($GLOBALS["appPhoneHome"],
6, 4))
Kirk
> -Origina
if they all have the same format, then you can do this (don't need regexs)
$number = '1234567890';
$formatted_number = '(' . substr($number,0,3) . ') ' . substr($number,3,3) .
'-' . substr($number,6);
-jack
-Original Message-
From: Jerry Lake [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, Ma
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 P
Jerry, try sprintf(). Here's an example:
sprintf("(%s) %s-%s", substr($GLOBALS["appPhoneHome"], 0,
3),substr($GLOBALS["appPhoneHome"], 3, 3),substr($GLOBALS["appPhoneHome"],
6, 4))
Kirk
> -Original Message-
> From: Jerry Lake [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 15, 2001 4:48
4 matches
Mail list logo