note 52603 deleted from function.fnmatch by victor
| From: | victor@php.net | Date: | Fri, 19 Aug 2005 11:31:36 +0000 |
| Subject: | note 52603 deleted from function.fnmatch by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-93890@lists.php.net to get a copy of this message | ||
Note Submitter: jcannonb at gmail dot com
----
I wrote a better SQL match. The other one had bugs in it:
function sql_match($pattern,$data)
{
$lpattern=strtolower($pattern);
$ldata=strtolower($data);
$lp=strlen($lpattern);
$ld=strlen($ldata);
$ip=0;
$id=0;
for ($ip=0; $ip<$lp; $ip++)
{
if ($lpattern[$ip]=='%')
{
$ip++;
if ($ip >= $lp)
{
return true;
}
for (;;)
{
if ($lpattern[$ip] == $ldata[$id])
{
break;
}
else
{
$id++;
if ($id > $ld)
{
return false;
}
}
}
}
if ($lpattern[$ip] <> $ldata[$id])
{
return false;
}
$id++;
}
if ($ld >= $lp)
{
if ($lpattern[$lp-1] != '%')
{
return false;
}
}
return true;
}