Join Up!
96807 members and counting!

 
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links 
search for in the  
previousflockfopennext
Last updated: Tue, 29 Oct 2002
view the printer friendly version or the printer friendly version with notes or change language to Czech | German

fnmatch

(PHP 4 CVS only)

fnmatch -- Match filename against a pattern

Description

array fnmatch ( string pattern, string string [, int flags])

fnmatch() checks if the passed string would match the given shell wildcard pattern.

This is especialy usefull 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() instead of ereg() or preg_match() for frontend search expression input may be way more convenient for non-programming users.

Ejemplo 1. Checking a color name against a shell wildcard pattern.

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

See also glob(), ereg(), preg_match() and the unix manpage on fnmatch(3) for flag names (as long as they are not documented here ).

User Contributed Notes
fnmatch
add a note about notes
There are no user contributed notes for this page.
previousflockfopennext
Last updated: Tue, 29 Oct 2002
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: http://phpbuilder.com/
Last updated: Thu Oct 31 18:34:28 2002 EST