In onderstaand script, worden afbeeldingen random getoont uit een map. Dit is de hoofdmap. Nu zou ik graag hebben dat hij uit submappen foto's haalt die mappen staan dan in de hoofmap. een voorbeeld van de structuur van een map is:
* Foto's School
- 3e graad
.5e jaar
.6e jaar
* = Hoofmap
- = 1e submap
. = 2e submap
<?php
include('config.php');
$dir = "../bbhum/fotoboek/albums/";
$rotator_width = '100px';
$rotator_height = '70px';
$dir = rand(0, $dirs);
function randomFotoMap($dir)
{
$picpad = opendir($dir);
while(false !== ($file = readdir($picpad)))
{
$ext = explode(".", $file);
strtolower($ext);
if ($ext[1] == "jpg")
{
$fotos[] = $file;
}
}
closedir($picpad);
$totaal = count($fotos);
srand((double)microtime()*1000000);
$n = rand(0,$totaal-1);
return $fotos[$n];
}
if($rotator_width != 0 && isset($rotator_width))
{
$width = " width=\"".$rotator_width."\"";
}else{
$width = "";
}
if($rotator_height != 0 && isset($rotator_height))
{
$height = " height=\"".$rotator_height."\"";
}else{
$height = "";
}
$fotos= randomFotoMap($dir);
echo "<img src=\"".$dir.$fotos."\"".$width.$height." alt=\"Willekeurige foto\" />";
?>