note 41123 added to function.glob

From: Date: Tue, 30 Mar 2004 22:52:55 +0000
Subject: note 41123 added to function.glob
Groups: php.notes 
Request: Send a blank email to php-notes+get-67397@lists.php.net to get a copy of this message
Just threw this together in response to a common question in irc: Available at: http://www.pgregg.com/projects/ http://www.pgregg.com/projects/php/code/preg_find.phps preg_find() - A function to search in a directory for files or directories matching a preg_ pattern. Tell it the pattern, the start directory and some optional flags and it will return an array of files and their associated stat() details. If you just want the filenames, just do an array_keys() on the result. e.g. $files = preg_find("/\.php$/", '.', PREG_FIND_RECURSIVE); will find all files ending in .php in the current directory and below. Options are: // PREG_FIND_RECURSIVE - go into subdirectorys looking for more files // PREG_FIND_DIRMATCH - return directorys that match the pattern also // PREG_FIND_FULLPATH - search for the pattern in the full path (dir+file) // PREG_FIND_NEGATE - return files that don't match the pattern // to use more than one simple seperate them with a | character Hope you find it useful. Paul. ---- Manual Page -- http://www.php.net/manual/en/function.glob.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41123 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41123&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41123&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67397) next »