PHP fnmatch() 函數(shù)
完整的 PHP Filesystem 參考手冊(cè)
定義和用法
fnmatch() 函數(shù)根據(jù)指定的模式來(lái)匹配文件名或字符串。
語(yǔ)法
fnmatch(pattern,string,flags)
參數(shù) | 描述 |
pattern | 必需。規(guī)定要檢索的模式。 |
string | 必需。規(guī)定要檢查的字符串或文件。 |
flags | 可選。 |
提示和注釋
注釋?zhuān)?/strong>該函數(shù)無(wú)法在 Windows 平臺(tái)上使用。
實(shí)例
根據(jù) shell 通配符模式來(lái)檢查顏色名:
<?php
$txt = "My car is darkgrey..."
if (fnmatch("*gr[ae]y",$txt))
{
echo "some form of gray ...";
}
?>
完整的 PHP Filesystem 參考手冊(cè)