Re: preg_match
| From: | Marek Kilimajer | Date: | Fri, 05 Dec 2003 13:26:58 +0000 |
| Subject: | Re: preg_match | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-171981@lists.php.net to get a copy of this message | ||
If $thumbname does not contain any regular expression syntax characters, it mean $item must begin with $thumbname to match the expression. Even a dot is a syntax character, the code should better be:
if (!preg_match("/^".preg_quote($thumbname)."/",$item))
preg_quote will escape special characters. But John's suggestion is better.
pete M wrote:
could someone explain what this bit of code does please... if (!preg_match("/^".$thumbname."/",$item)) { } tia PEte