PHP fnmatch() 函數

2018-11-21 16:07 更新

PHP fnmatch() 函數


PHP Filesystem 參考手冊 完整的 PHP Filesystem 參考手冊

定義和用法

fnmatch() 函數根據指定的模式來匹配文件名或字符串。

語法

fnmatch(pattern,string,flags)

參數 描述
pattern 必需。規(guī)定要檢索的模式。
string 必需。規(guī)定要檢查的字符串或文件。
flags 可選。


提示和注釋

注釋:該函數無法在 Windows 平臺上使用。


實例

根據 shell 通配符模式來檢查顏色名:

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


PHP Filesystem 參考手冊 完整的 PHP Filesystem 參考手冊
以上內容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號