|
Posted by Krustov on 05/08/07 23:25
<comp.lang.php>
<laredotornado@zipmail.com>
<7 May 2007 12:56:49 -0700>
<1178567809.585694.21720@y80g2000hsf.googlegroups.com>
> $p = "5558675309";
> $p = "(312) 123-4567";
> $p = "512-234-5678";
>
> Thanks for any code snippets
>
What you could do is strip everything from the phone number string
except the 0123456789 and then reform it to anything you want .
The substr() stuff hasnt been checked .
<?php
$p="(312) 123-4567";
$dummy=$p; include('the_file_below.php'); $p=$dummy;
$p1=substr($p,0,3);
$p2=substr($p,4,3);
$p3=substr($p,9,4);
$poop="(" . $p1 . ")" . " " . $p2 . "-" . $p3;
?>
<?php
$ok="1234567890";
$zstring=strlen($ok);
$zdummy=strlen($dummy);
$jazz=0;
while ($jazz<256)
{
$homer[$jazz]=0;
$jazz=$jazz+1;
}
$jazz=0;
while ($jazz<$zstring)
{
$junk=substr($ok,$jazz,1); $qaz=ord($junk); $homer[$qaz]=1;
$jazz=$jazz+1;
}
$gimmie="";
if ($zdummy>0)
{
$jazz=0;
while ($jazz<$zdummy)
{
$junk=substr($dummy,$jazz,1); $qaz=ord($junk);
if ($homer[$qaz]==1) {$gimmie=$gimmie . $junk;}
$jazz=$jazz+1;
}
}
$dummy=$gimmie;
?>
Navigation:
[Reply to this message]
|