
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
fnmatch() function in PHP
The fnmatch() function matches a filename or string against a specified pattern.
Syntax
fnmatch(pattern, string, flags)
Parameters
pattern − The pattern to search.
string − The string to test.
flags − Any of the following values:
FNM_NOESCAPE − Disable backslash escaping
FNM_PATHNAME − Slash in string only matches slash in the given pattern.
FNM_PERIOD − Leading period in string must be exactly matched by period in the given pattern.
Return
The fnmatch() function returns TRUE if it is a match, else FALSE.
The following is an example showing wildcard pattern.
Example
<?php $file = "organization.txt"; if (fnmatch("*organi[zs]ation",$file)) { echo "Found!"; } else { echo "Not found!"; } ?>
Output
Not found!
- Related Articles
- Unix filename pattern matching in Python (fnmatch)
- filter_has_var() function in PHP
- filter_id() function in PHP
- filter_input() function in PHP
- filter_input_array() function in PHP
- filter_list() function in PHP
- filter_var_array() function in PHP
- filter_var() function in PHP
- constant() function in PHP
- define() function in PHP
- defined() function in PHP
- die() function in PHP
- eval() function in PHP
- exit() function in PHP
- get_browser() function in PHP

Advertisements