Php fnmatch file name matching mode

Source: Internet
Author: User

Fnmatch
("= 4.3.0, PHP 5" in PHP 4)

Fnmatch-match a file name

Description
Boolean fnmatch (string $ mode, string $ string [Summary $ flag = 0])
Fnmatch () check, if the given Shell wildcard pattern will be matched by a string.

Parameters

Mode
In shell wildcard mode.

String
Test string. This feature is particularly useful for file names, but can also be used for common strings.

Generally, the user can use shell mode, or at least in its simplest form '? The 'and' * 'wildcards use fnmatch (), instead of the preg_match () frontend input search expression, which may be more convenient for non-programmed users.

Flag
A FNM_XXX constant.


Return value
Returns TRUE if there is a race, false in other ways.

Modify

Version description
5.3.0 is now available on Windows.


Instance

For example, #1 check the color name for a shell wildcard pattern

<? Php
If (fnmatch ("* gr [AE] y", $ color )){
Echo "some form of gray ...";
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.