note 74951 deleted from function.readdir by nlopess

From: Date: Sat, 12 May 2007 11:33:53 +0000
Subject: note 74951 deleted from function.readdir by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126452@lists.php.net to get a copy of this message
Note Submitter: Paul Gregg (Qube #php @ Efnet) ---- Here is an updated version of preg_find() [which has been linked from the glob() man page for years] - this function should provide most of what you want back from reading files, directories, different sorting methods, recursion, and perhaps most powerful of all the ability to pattern match with a PCRE regex. You can get preg_find here: http://www.pgregg.com/projects/php/preg_find/preg_find.php.txt or if you prefer colourful .phps format: http://www.pgregg.com/projects/php/preg_find/preg_find.phps or scoll down to the end of this note. I wrote several examples on how to use it on my blog at: http://www.pgregg.com/forums/viewtopic.php?tid=73 simple glob() type replacement: $files = preg_find('/./', $dir); recursive? $files = preg_find('/./', $dir, PREG_FIND_RECURSIVE); pattern match? find all .php files: $files = preg_find('/\.php$/D', $dir, PREG_FIND_RECURSIVE); sorted alphabetically? $files = preg_find('/\.php$/D', $dir, PREG_FIND_RECURSIVE|PREG_FIND_SORTKEYS); sorted in by filesize, in descending order? $files = preg_find('/./', $dir, PREG_FIND_RECURSIVE|PREG_FIND_RETURNASSOC |PREG_FIND_SORTFILESIZE|PREG_FIND_SORTDESC); $files=array_keys($files); sorted by date modified? $files = preg_find('/./', $dir, PREG_FIND_RECURSIVE|PREG_FIND_RETURNASSOC |PREG_FIND_SORTMODIFIED); $files=array_keys($files); Ok, the PHP note says my note is too long, so please click on one of the above links to get it.

« previous php.notes (#126452) next »