
Originally Posted by
clamcrusher
yes, you must define a function before you can use it.
Alright its working partly now.
I have
PHP Code:
<?php
function folderlist(){
$startdir = './';
$ignoredDirectory[] = '.';
$ignoredDirectory[] = '..';
if (is_dir($startdir)){
if ($dh = opendir($startdir)){
while (($folder = readdir($dh)) !== false){
if (!(array_search($folder,$ignoredDirectory) > -1)){
if (filetype($startdir . $folder) == "dir"){
$directorylist[$startdir . $folder]['name'] = $folder;
$directorylist[$startdir . $folder]['path'] = $startdir;
}
}
}
closedir($dh);
}
}
return($directorylist);
}
if (empty($_SESSION['folders'])) {
$_SESSION['folders'] = folderlist();
shuffle($_SESSION['folders']);
}
$folder = array_pop($_SESSION['folders']);
print_r($folder);
?>
And I have folders 1,2,3 in the directory. It's showing this:
PHP Code:
Array ( [name] => 1 [path] => ./ )
Bookmarks