jamesl2222 Posted January 6, 2007 Share Posted January 6, 2007 Hi guys, whilst the script works fine on files.. I need to return the directory name instead . Can anyone helpfunction adir2($dirname2) {$handle2=opendir($dirname2); $dirarray2 = array();while ($file2 = readdir($handle2)) {if ($file2 > "..") {array_push($dirarray2,$file2);}}closedir($handle2);return $dirarray2;}function randdir2($dirname2) {srand ((double) microtime() * 10000000);$dirarray2 = adir2($dirname2);$rndfile2 = array_rand($dirarray2);return $dirarray2[$rndfile2];}function print_array2($array) { if(gettype($array2)=="array") { echo "<ul>"; while (list($index, $subarray) = each($array) ) { echo "<li>$index <code>=></code> "; print_array($subarray); echo "</li>"; } echo "</ul>"; } else echo $array; } Link to comment https://forums.phpfreaks.com/topic/33083-help-with-a-php-script-please/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.