Posted by Krustov on 07/05/06 18:58
<comp.lang.php>
<Krustov>
<Wed, 5 Jul 2006 17:08:24 +0100>
<MPG.1f15f4355f47a240989b50@news.newsreader.com>
> I havent got my head round regular expressions yet either - but it would
> be easy to write a small loop to replace everything that wasnt
> 012345678/. with a space .
>
> Can write it for you if you want .
>
Wrote it anyway as it could be useful to me some time in the future .
Quite luddite in method but seems to work fine .
<?php
$num="A_555. 01/2345jack678-90/.@Z";
print "Before processing = $num <br>";
include('number_check.php');
print "After processing = $fin <br>";
?>
The above on some webpage .
The following as a include file .
number_check.php
<?php
$ok="0123456789/.";
$clown=strlen($ok); $clown=$clown-1;
$lisa=0;
while($lisa<$clown+1)
{
$char=substr($ok,$lisa,1);
$millhouse[$lisa]=$char;
$lisa=$lisa+1;
}
$krusty=strlen($num); $krusty=$krusty-1;
$lisa=0;
while($lisa<$krusty+1)
{
$char=substr($num,$lisa,1);
$jimbo[$lisa]=$char;
$lisa=$lisa+1;
}
$lisa=0; $fin="";
while($lisa<$krusty+1)
{
$homer=0; $pass=0;
while ($homer<$clown+1)
{
if ($jimbo[$lisa]==$millhouse[$homer]) {$pass=1;}
$homer=$homer+1;
}
if ($pass==0) {$jimbo[$lisa]=" ";}
$fin=$fin . $jimbo[$lisa];
$lisa=$lisa+1;
}
?>
--
Encrypted email address
www.emailuser.co.uk/?name=KRUSTOV
[Back to original message]
|