php man page for fnmatch

Query: fnmatch

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

FNMATCH(3)								 1								FNMATCH(3)

fnmatch - Match filename against a pattern

SYNOPSIS
bool fnmatch (string $pattern, string $string, [int $flags])
DESCRIPTION
fnmatch(3) checks if the passed $string would match the given shell wildcard $pattern.
PARAMETERS
o $pattern - The shell wildcard pattern. o $string - The tested string. This function is especially useful for filenames, but may also be used on regular strings. The average user may be used to shell patterns or at least in their simplest form to '?' and '*' wildcards so using fnmatch(3) instead of preg_match(3) for frontend search expression input may be way more convenient for non-programming users. o $flags - The value of $flags can be any combination of the following flags, joined with the binary OR (|) operator. A list of possible flags for fnmatch(3) +-------------+---------------------------------------------------+ | $Flag | | | | | | | Description | | | | +-------------+---------------------------------------------------+ | | | |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. | | | | | | | |FNM_CASEFOLD | | | | | | | Caseless match. Part of the GNU extension. | | | | +-------------+---------------------------------------------------+
RETURN VALUES
Returns TRUE if there is a match, FALSE otherwise.
CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | This function is now available on Windows plat- | | | forms. | | | | +--------+---------------------------------------------------+
EXAMPLES
Example #1 Checking a color name against a shell wildcard pattern <?php if (fnmatch("*gr[ae]y", $color)) { echo "some form of gray ..."; } ?>
NOTES
Warning For now, this function is not available on non-POSIX compliant systems except Windows.
SEE ALSO
glob(3), preg_match(3), sscanf(3), printf(3), sprintf(3). PHP Documentation Group FNMATCH(3)
Related Man Pages
fnmatch(3) - osx
fnmatch(3) - netbsd
fnmatch(3) - php
fnmatch(3) - bsd
fnmatch(3) - v7
Similar Topics in the Unix Linux Community
Find string in list with wildcards
Extract a pattern from file
More sed/awk help
Replace a string in a file
[SOLVED] Replace a string in nextline after searching a pattern