PHP fnmatch() 函數
定義和用法
fnmatch() 函數根據指定的模式來匹配文件名或字符串。
語法
fnmatch(pattern,string,flags)
参数 | 描述 |
---|---|
pattern | 必需。规定要检索的模式。 |
string | 必需。规定要检查的字符串或文件。 |
flags | 可选。 |
提示和註釋
註釋:該函數無法在Windows平台上使用。
實例
根據shell 通配符模式來檢查顏色名:
<?php
$txt = "My car is darkgrey..."
if (fnmatch("*gr[ae]y",$txt))
{
echo "some form of gray ...";
}
?>
$txt = "My car is darkgrey..."
if (fnmatch("*gr[ae]y",$txt))
{
echo "some form of gray ...";
}
?>
完整的PHP Filesystem參考手冊