Re: Re: reading/parsing file names
| From: | John Nichel | Date: | Sat, 25 Oct 2003 23:30:24 +0000 |
| Subject: | Re: Re: reading/parsing file names | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-167599@lists.php.net to get a copy of this message | ||
koly wrote:
In article <koly-ADA993.15414725102003@pb1.pair.com>, koly@koly.com (Koly) wrote:You could use a regular expression.... if ( preg_match ( "/\.thumb\.jpg$/", $file ) ) { some code... } I prefer the Perl regex's because I know it, but the POSIX style seems to be more popular with the PHP 'in' crowd. :) Perl RegEx : http://us2.php.net/manual/en/ref.pcre.php POSIX RegEx : http://us2.php.net/manual/en/ref.regex.php -- By-Tor.com It's all about the Rush http://www.by-tor.commy problem: I've got a list of files in a directory, and I'd like to get a only of filenames that end in ".jpg", however, exlude the files that end in ".thumb.jpg" ex: file.php index.htm photo.jpg photo.thumb.jpg etc how can I count only those files that end with ".jpg" ? Any help appreciated.sorry, after re-reading, I'm not sure this post makes sense - I'd like to get a count of all the ".jpg" files in a specific directory and exclude all other files. Secondarily, I'd like to be able to refer to only ".thumb.jpg" files for another instance (displaying those images) - but I assume once I figure out how to parse/explode/read/exclude unwanted random file names, I'll be able to figure out how to look for specific file names I want. Basically, I need a kind of wildcard filename parse? Something like: if($file == '*.thumb.jpg')