Hallo iedereen,
Onderstaand een script dat ik gebruik om foto's uit een map te halen en daarna weer te geven in diverse kolommen.
Nu zou ik graag de foto's sorteren op bestandsnaam, ik heb enkel geen idee
hoe dit te doen !
Kunnen jullie mij helpen?
Groeten
Jeroen
<?php
$image_types = array("jpg","gif","bmp","png","jpeg");
$plaatjes_reeks = "";
$mapnaam = '/private-album/'.$album;
if ( ereg('..',$mapnaam) || ereg('//',$mapnaam) ){
$mapnaam = '/private-album/'.$album;
}
$map = opendir(".{$mapnaam}");
$count = 0;
while (false!==($bestand = readdir($map))) {
if ($bestand != "." && $bestand != "..") {
$ext = explode('.',$bestand);
$extl = sizeof($ext) - 1;
$ext = strtolower($ext[$extl]);
if ( in_array($ext,$image_types) ){
if($count%7 == 0) {
$plaatjes_reeks .= '<div style="clear:both;"></div>';
}
$fotonaam = str_replace(".jpg", "", $bestand);
natsort($plaatjes_reeks);
foreach ($plaatjes_reeks as $id => $plaatje)
{
$plaatjes_reeks .= "<div style='float:left; margin-bottom:5px; margin-right:5px;'>
<a href=\"private-album/".$album.'/'. $bestand . "\" title='".$fotonaam." © Bram Vloemans Photography ".date('Y')."'> <img src=\"private-album/".$album.'/thumbs/'. $bestand . "\" width='150' height='125' alt='' style='border: #000 2px solid' /></a>
</div>";
$count++;
}
}
}
}
if ( $plaatjes_reeks != "" ){
echo ($plaatjes_reeks);
}
closedir($map);
?>
2.380 views