note 5600 modified in readdir by ronabop

From: Date: Fri, 03 Nov 2000 03:58:58 +0000
Subject: note 5600 modified in readdir by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-7323@lists.php.net to get a copy of this message
Taking the GetDirArray() function above and adding some recurssion in to list the entire contents of a dir and the tree below: function GetDirArray($sPath) { //Load Directory Into Array $handle=opendir($sPath); while ($file = readdir($handle)) { $retVal[count($retVal)] = $file; } //Clean up and sort closedir($handle); sort($retVal); //return $retVal; while (list($key, $val) = each($retVal)) { if ($val != "." && $val != "..") { $path = str_replace("//","/",$sPath.$val); echo "$path<br>"; if (is_dir($sPath.$val)) { GetDirArray($sPath.$val."/"); } } } } http://www.php.net/manual/function.readdir.php

« previous php.notes (#7323) next »