PHP -Sortierarray nach Nummer im DateinamenPhp

PHP-Programmierer chatten hier
Anonymous
 PHP -Sortierarray nach Nummer im Dateinamen

Post by Anonymous »

Ich arbeite an einer Fotogalerie, die die Fotos automatisch basierend auf den Nummern des Dateinamens sortiert. < /p>

Ich habe den folgenden Code: < /p> < Br />

Code: Select all

//calculate and sort
$totaal = 0;
if($handle_thumbs = opendir('thumbs')){
$files_thumbs = array();
while(false !== ($file = readdir($handle_thumbs))){
if($file != "." && $file != ".."){
$files_thumbs[] = $file;
$totaal++;
}
}
closedir($handle_thumbs);
}
sort($files_thumbs);

//reset array list
$first = reset($files_thumbs);
$last = end($files_thumbs);
//match and split filenames from array values - image numbers
preg_match("/(\d+(?:-\d+)*)/", "$first", $matches);
$firstimage = $matches[1];
preg_match("/(\d+(?:-\d+)*)/", "$last", $matches);
$lastimage = $matches[1];
, aber wenn ich Dateinamen wie Photo-Aname_0333.jpg , foto-bname_0222.jpg habe, beginnt es mit dem Photo-Aname_0333 anstelle des 0222 .>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post