PHP fnmatch() Function
Definition
The fnmatch() function matches a filename or string against the specified pattern.
This function is not implemented on Windows platforms.
Syntax
PHP fnmatch() Function has the following syntax.
fnmatch(pattern,string,flags)
Parameter
Parameter | Is Required | Description |
---|---|---|
pattern | Required. | Pattern to search for |
string | Required. | String or file check |
flags | Optional. | Option |
Return
Returns TRUE if there is a match, FALSE otherwise.
Example
Checking a file name against a shell wildcard pattern:
<?php//from w w w . ja va2 s . com
$txt = "test.txt";
if (fnmatch("*[t]*",$txt)){
echo "test...";
}
?>
The code above generates the following result.