Latest web development tutorials

PHP fnmatch () function

PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual

Definition and Usage

fnmatch () function to match the specified pattern or file name string.

grammar

fnmatch(pattern,string,flags)

参数 描述
pattern 必需。规定要检索的模式。
string 必需。规定要检查的字符串或文件。
flags 可选。


Tips and Notes

Note: This function is not available on Windows platforms.


Examples

According shell wildcard pattern to check the color name:

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


PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual