note 94116 deleted from function.opendir by cmb

From: Date: Tue, 11 Jun 2019 06:36:38 +0000
Subject: note 94116 deleted from function.opendir by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211213@lists.php.net to get a copy of this message
Note Submitter: diego at moon-sand dot net ---- 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; } ?>

« previous php.notes (#211213) next »