note 100191 deleted from function.fnmatch by danbrown

From: Date: Fri, 01 Oct 2010 12:00:04 +0000
Subject: note 100191 deleted from function.fnmatch by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172870@lists.php.net to get a copy of this message
Note Submitter: me at rowanlewis dot com ---- Here's a definitive solution, which supports negative character classes <?php if (!function_exists('fnmatch')) { define('FNM_PATHNAME', 1); define('FNM_PERIOD', 4); define('FNM_NOESCAPE', 2); define('FNM_FILE_NAME', FNM_PATHNAME); define('FNM_LEADING_DIR', 8); define('FNM_CASEFOLD', 16); function fnmatch($pattern, $string) { $pattern = strtr( preg_quote($pattern, '#'), array( '\*' => '.*', '\?' => '.', '\[\!' => '[^', '\[' => '[', '\]' => ']' ) ); return (boolean)preg_match('#^' . $pattern . '$#i', $string); } } ?>

« previous php.notes (#172870) next »