Home  >  Article  >  Backend Development  >  php fnmatch file name matching pattern_PHP tutorial

php fnmatch file name matching pattern_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:01:121160browse

php fnmatch file name matching pattern ​

fnmatch
(PHP 4" = 4.3.0, PHP 5)

fnmatch - Match pattern
on a filename
Description
boolean fnmatch(string$pattern, string$string[abstract$flag=0])
fnmatch() checks if a given shell wildcard pattern will be matched by a string.

Parameters

Pattern
Wildcard pattern in shell.

String
Test string. This function is particularly useful for filenames, but can also be used for ordinary strings.

The average user can use Shell mode, or at least in its simplest form, to '? ' and ' * ' wildcards so using fnmatch() instead of preg_match() as the front-end input search expression may be more convenient for non-programming users.

Flag
A FNM_XXX constant.


Return value
Returns TRUE if there is a match, false otherwise.

Modify

Release Notes
5.3.0 This feature is now available on Windows platforms.


Example

Example #1 Check color names against a shell wildcard pattern

if (fnmatch("*gr[ae]y", $color)) {
echo "some form of gray ...";
}
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445465.htmlTechArticlephp fnmatch filename matching pattern fnmatch (PHP 4 = 4.3.0, PHP 5) fnmatch - pair of a filenamematch pattern description boolean fnmatch(string$pattern, string$string...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn