note 31253 deleted from function.fnmatch by victor
| From: | victor@php.net | Date: | Fri, 19 Aug 2005 11:30:29 +0000 |
| Subject: | note 31253 deleted from function.fnmatch by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-93885@lists.php.net to get a copy of this message | ||
Note Submitter: me at lejfdiecks dot de
----
I had the same problem ("Call to undefined function: fnmatch()") using PHP 4.2.3 on a
hosted webserver; so I wrote "my own" fnmatch(). Hope it helps someone:
function fnmatch($strPattern, $strString)
// My fnmatch()
// Supports '?' and '*' as wildcards
{
$intPos = 0;
do
{
$strPatternChar = substr($strPattern, $intPos, 1);
$strStringChar = substr($strString, $intPos, 1);
if ($strPatternChar == '*')
{
$bolMatch = TRUE;
break;
}
$bolMatch = ($strPatternChar == $strStringChar) || ($strPatternChar == '?' &&
$strStringChar != '');
$intPos++;
} while (($bolMatch == TRUE) && ($intPos < max(strlen($strPattern),
strlen($strString))));
return($bolMatch);
}
// Main program - test fnmatch() function
if (fnmatch('te?t', 'test'))
echo "Pattern <b>matches</b> string.";
else
echo "Pattern <b>does not</b> match string.";