Scan through directories with wildcards

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

Jenk wrote:You could integrate http://us2.php.net/manual/en/function.fnmatch.php or just plain old preg_match().

Code: Select all

foreach (glob($dir . '/*') as $file)
{
    if (preg_match('/' . $pattern . '/i', $file)) $files[] = $file;
}
Woohoo! That code worked. Thanks mate.
Post Reply