fnmatch
Match file names with pattern
The fnmatch()
function matches file names or strings based on the specified pattern.
Check the color name according to the shell wildcard:
<?php $txt = "My car is darkgrey..." if ( fnmatch ( "*gr[ae]y" , $txt ) ) { echo "some form of gray..." ; } ?>
fnmatch ( pattern , string , flags )
parameter | describe |
---|---|
pattern | Required. Specify the mode to be retrieved. |
string | Required. Specifies the string or file to be checked. |
flags | Optional. |
This function is especially useful for file names, but can also be used for normal strings. Ordinary users may be accustomed to shell mode or at least the simplest forms of '?' and '*' wildcards, so using fnmatch()
instead of ereg()
or preg_match()
for front-end search expression input is more convenient for non-programmer users.