Revision: 40281
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 28, 2011 19:28 by bionickid
Initial Code
/*
* Example:
*
* 0049 1136 - 180-0 +49 1136 1800
* +49-89-66878-6402 +49 8966 8786 402
* 0049 2223 34-1325 +49 2223 341325
* +49 (0)88 99147687 +49 8899 147687
*/
function phone_number($phone)
{
$steps = 5;
$phoneBAK = $phone = preg_replace("/[^0-9+]/", '', str_replace(array(' ','(0)'),'', $phone));
while($phone[0]==0) $phone = substr($phone, 1);
if(substr($phone, 0, 2)==49) {
$phone = "+".substr($phone, 0, 2)." ".substr($phone, 2);
$start = $steps+3;
}
else {
$phone = $phoneBAK;
$start = $steps;
}
for($i=$start;$i<strlen($phone);$i=$i+$steps) $phone = substr_replace($phone, ' ', $i,0);
$end = strrchr($phone, ' ');
if(strlen($end)<4) $phone = substr($phone, 0, 0-strlen($end)) . substr($phone, 0-strlen($end)+1);
return $phone;
}
Initial URL
Initial Description
Built for german numbers.
Initial Title
Phone Number Beautifier
Initial Tags
phone
Initial Language
PHP