PHP fnmatch() Function
❮ PHP Filesystem ReferenceExample
Checking a color name against a shell wildcard pattern:
<?php
$txt = "My car is a dark color";
if (fnmatch("*col[ou]r",$txt))
{
echo "hmm...";
}
?>
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:
|
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