|
function directoryToArray($directory, $recursive) {
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($directory. "/" . $file)) {
if($recursive) {
$array_items = array_merge($array_items, directoryToArray($directory. "/" . $file, $recursive));
}
//$file = $directory . "/" . $file;
//$array_items[] = preg_replace("/\/\//si", "/", $file);
//remove dirs from list
} else {
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\/\//si", "/", $file);
}
}
}
closedir($handle);
}
return $array_items;
}
$files=directorytoArray("gallery",false); foreach($files as $nul => $file){$file=str_replace("gallery/","",$file); if(trim($file)!=""){ ?>
">" alt="Gallery Image"> }} ?>
|