PHP fnmatch()Functions


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual

Definition and Usage

The fnmatch() function matches a filename or string against the specified pattern.

Syntax

fnmatch(pattern,string,flags)

Parameter Description
pattern Required. Specifies the pattern to search for.
string Required. Specifies the string or file to check.
flags Optional.


Tips and Notes

Note:This function is not available on the Windows platform.


Examples

Check a color name against a shell wildcard pattern:

<?php
$txt = "My car is darkgrey..."
if (fnmatch("*gr[ae]y",$txt))
{
echo "some form of gray ...";
}
?>


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual Other Extensions