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