Poon, Kelvin (Infomart) wrote: [ snip ]
> My problem is I don't know how to open all of the files in the directory,
> since I don't know the name of the files. These php files keep updating,
> and the names would be KB_XXXXXX.php, where XXXXXX is the ID of that
> particular file. I need to open ALL of these files and search the phrase in
> it. Any body have any idea how I can open these files? I am probably going
> to be using RE to search, so maybe I can use fread() to store a file in a
> variable and search one file at a time.
This little function will return all the files in a directory as an array. Hope this helps :
function getFiles($dirname) {
$handle=opendir($dirname); while ($file = readdir($handle)) { if($file=='.'||$file=='..') continue; else $result_array[]=$file; } closedir($handle); return $result_array; }
Call it like this : $file_list = getFiles("/parent/sub");
Regards, -- Burhan Khalid phplist[at]meidomus[dot]com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php