note 26996 added to function.sscanf
| From: | sbarnum dot pointsystems at com dot php dot net | Date: | Wed, 20 Nov 2002 01:21:41 +0000 |
| Subject: | note 26996 added to function.sscanf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-39717@lists.php.net to get a copy of this message | ||
More fun with phones! This assumes that the phone number is 10 digits, with only numeric data, but
it would be easy to check the length of the string first.
function formatPhone($phone) {
if (empty($phone)) return "";
sscanf($phone, "%3d%3d%4d", $area, $prefix, $exchange);
$out = @$area ? "($area) " : "";
$out .= $prefix . '-' . $exchange;
return $out;
}
--
http://www.php.net/manual/en/function.sscanf.php
http://master.php.net/manage/user-notes.php?action=edit+26996
http://master.php.net/manage/user-notes.php?action=delete+26996
http://master.php.net/manage/user-notes.php?action=reject+26996