Sorter billeder i mappe
Hvordan sorterer jeg disse billeder i numerisk rækkefølge?<?
$mappe=$billede2."/pics/";
function list_dir($mappe)
{
if($mappe[strlen($mappe)-1]!='')
$mappe.='';
static $result_array=array();
$handle=opendir($mappe);
while ($file = readdir($handle)) {
if($file=='.'||$file=='..')
continue;
if(is_dir($mappe.$file))
list_dir($mappe.$file.'\\');
else
$result_array[]=$mappe.$file;
}
closedir($handle);
return $result_array;
}
function images_left($mappe, $current_image) {
$total_images = list_dir($mappe) ;
$total_images = count($total_images) ;
$left = $total_images - $current_image ;
return $left ;
}
if (!$taeller) {
$taeller = 0 ;
setcookie("taeller", 0, time() + 0) ;
}
if ($page == "next") {
$taeller = $taeller + 1 ;
} else if ($page == "back") {
$taeller = $taeller - 1 ;
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="hnclude/style.css">
<title>Billede</title>
<script language='javascript' src='include/resize.js'></script>
</head>
<body onload='VisBillede();' topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0 scroll="auto">
<?php
if ($mappe) {
$antal_billeder = list_dir($mappe) ;
$antal = count($antal_billeder) ;
echo $taeller."/".$antal."<br>";
$billede = $antal_billeder[$taeller] ;
echo "<img src='$billede' alt='' NAME=\"pic\"><br>" ;
if($taeller==0){
echo "Forrige " ;
}else{
echo "<a href='imageopen.php?mappe=" . $mappe . "&page=back&billede2=$billede2&taeller=$taeller'>Forrige</a> " ;
}
if($antal==$taeller+1){
echo "Næste " ;
}else{
echo "<a href='imageopen.php?mappe=" . $mappe . "&page=next&billede2=$billede2&taeller=$taeller'>Næste</a> " ;
}
}
?>
</body>
</html>
