Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Sortowanie plików
Vasquez21
post
Post #1





Grupa: Zarejestrowani
Postów: 213
Pomógł: 0
Dołączył: 2.11.2004
Skąd: Jaworzno

Ostrzeżenie: (0%)
-----


Witam wszystkich,

Mam problemik mianowicie wgrałem sobie skrypcik który wgrywa pliczki na serwer. Dodatkowo wyświetlam ich liste, ale mam problem z posortowaniem tej listy.
Byłbym wdzięczny gdyby ktoś pomógł mi zmodyfikować ten fragment kodu odpowiedzialny za czytanie plików z lokalizacji:

  1. $imgdir = '../../img/uploads/'; //Pick your folder
  2. $allowed_types = array('png','jpg','jpeg','gif'); //Allowed types of files
  3. $dimg = opendir($imgdir);//Open directory
  4. while($imgfile = readdir($dimg))
  5. {
  6. if( in_array(strtolower(substr($imgfile,-3)),$allowed_types) OR
  7. in_array(strtolower(substr($imgfile,-4)),$allowed_types) )
  8. /*If the file is an image add it to the array*/
  9. {$a_img[] = $imgfile;}
  10. }
  11. echo "<ul style='color:black;'>";
  12.  
  13. $totimg = count($a_img); //The total count of all the images
  14. //Echo out the images and their paths incased in an li.
  15. for($x=0; $x < $totimg; $x++){echo '<li><a href="../../img/uploads/'.$a_img[$x].'" class="preview" target="_new">'.$a_img[$x].'</a></li>';}
  16. echo "</ul>";
Go to the top of the page
+Quote Post

Posty w temacie
- Vasquez21   Sortowanie plików   8.03.2015, 21:45:10
- - com   Skorzystaj z http://php.net/manual/en/array.sortin...   8.03.2015, 22:59:36


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 15:29