PHP fnmatch() Function

Checking a color name against a shell wildcard pattern

Definition and Usage

The fnmatch() function checks if a string or filename matches the given shell wildcard pattern.

Syntax

fnmatch(pattern, string, flags)

Parameter Values

Parameter Description
pattern Required. Specifies the shell wildcard pattern
string Required. Specifies the string or file to check
flags Optional. Can be one or a combination of the following:
  • FNM_NOESCAPE - Disable backslash escaping
  • FNM_PATHNAME - Slash in string only matches slash in the given pattern
  • FNM_PERIOD - Leading period in string must be exactly matched by period in pattern
  • FNM_CASEFOLD - Caseless match. Part of the GNU extension

Technical Details

Return Value: TRUE on success, FALSE on failure
PHP Version: 4.3+
PHP Changelog: PHP 5.3: Now available on Windows platforms

❮ PHP Filesystem Reference