PHP fnmatch() Function
❮ Complete PHP Filesystem Reference
Definition and Usage
The fnmatch() function matches a filename or string against the specified pattern.
Syntax
fnmatch(pattern,string,flags)
Parameter | Description |
---|---|
pattern | Required. Specifies the pattern to search for |
string | Required. Specifies the string or file check |
flags | Optional. |
Tips and Notes
Note: This function is not implemented on Windows platforms.
Example
Checking a color name against a shell wildcard pattern:
<?php
$txt = "My car is darkgrey..."
if (fnmatch("*gr[ae]y",$txt))
{
echo "some form of gray ...";
}
?>
❮ Complete PHP Filesystem Reference