note 94116 added to function.opendir

From: Date: Fri, 16 Oct 2009 23:49:42 +0000
Subject: note 94116 added to function.opendir
Groups: php.notes 
Request: Send a blank email to php-notes+get-161826@lists.php.net to get a copy of this message
Correction on the previous function. Was missing full path on recursive line. <? function file_array($path, $exclude = ".|..", $recursive = true) { $path = rtrim($path, "/") . "/"; $folder_handle = opendir($path); $exclude_array = explode("|", $exclude); $result = array(); while(false !== ($filename = readdir($folder_handle))) { if(!in_array(strtolower($filename), $exclude_array)) { if(is_dir($path . $filename . "/")) { // Need to include full "path" or it's an infinite loop if($recursive) $result[] = file_array($path . $filename . "/", $exclude, true); } else { $result[] = $filename; } } } return $result; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 216.237.45.226 ---- Manual Page -- http://www.php.net/manual/en/function.opendir.php Edit -- https://master.php.net/note/edit/94116 Del: integrated -- https://master.php.net/note/delete/94116/integrated Del: useless -- https://master.php.net/note/delete/94116/useless Del: bad code -- https://master.php.net/note/delete/94116/bad+code Del: spam -- https://master.php.net/note/delete/94116/spam Del: non-english -- https://master.php.net/note/delete/94116/non-english Del: in docs -- https://master.php.net/note/delete/94116/in+docs Del: other reasons-- https://master.php.net/note/delete/94116 Reject -- https://master.php.net/note/reject/94116 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161826) next »