fnmatch() 函數根據指定的模式匹配文件名或字符串。
用法
fnmatch(pattern, string, flags)
參數
pattern −要搜索的模式。
string −要測試的字符串。
flags −以下任何值:
FNM_NOESCAPE −禁用反斜杠轉義
FNM_PATHNAME −字符串中的斜線隻匹配給定模式中的斜線。
FNM_PERIOD −字符串中的前導句點必須與給定模式中的句點完全匹配。
返回
如果匹配,則 fnmatch() 函數返回 TRUE,否則返回 FALSE。
以下是顯示通配符模式的示例。
示例
<?php
$file = "organization.txt";
if (fnmatch("*organi[zs]ation",$file)) {
echo "Found!";
} else {
echo "Not found!";
}
?>
輸出
Not found!
相關用法
- PHP fnmatch( )用法及代碼示例
- PHP fwrite( )用法及代碼示例
- PHP ftruncate( )用法及代碼示例
- PHP ftp_rawlist()用法及代碼示例
- PHP flock()用法及代碼示例
- PHP fileowner()用法及代碼示例
- PHP ftp_close()用法及代碼示例
- PHP fgets()用法及代碼示例
- PHP fileperms()用法及代碼示例
- PHP function_exists()用法及代碼示例
- PHP fmod()用法及代碼示例
- PHP ftp_nb_put()用法及代碼示例
- PHP fputs()用法及代碼示例
- PHP ftp_chmod()用法及代碼示例
- PHP filter_id()用法及代碼示例
- PHP ftp_nb_fget()用法及代碼示例
- PHP fgetc()用法及代碼示例
- PHP ftell( )用法及代碼示例
- PHP fputs( )用法及代碼示例
- PHP fpassthru()用法及代碼示例
注:本文由純淨天空篩選整理自Karthikeya Boyini大神的英文原創作品 fnmatch() function in PHP。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。