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 ..."; }?>