Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Sortowanie funkcji dir()
--Jakub--
post
Post #1





Goście







mam skrypt który otwiera katalog i wylistowuje wszystkie pliki. niestety sa one pomieszane:

filename: 10.jpg
filename: 29.jpg
filename: 16.jpg
filename: 28.jpg
filename: 33.jpg
filename: 14.jpg
filename: 37.jpg
filename: 30.jpg
filename: delfin9.jpg
filename: delfin7.jpg
filename: 20.jpg
filename: 17.jpg

potrzebuje aby ten skrypt:

  1. <?php
  2.  
  3. $dir = dir("images/");
  4. while (($file = $dir->read()) !== false)
  5. {
  6. echo "filename: " . $file . "<br />";
  7. }$dir->close();
  8.  
  9. ?>


sortował wyniki alfabetyznie.

pozdrawiam, Jakub
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
pyro
post
Post #2





Grupa: Zarejestrowani
Postów: 2 148
Pomógł: 230
Dołączył: 26.03.2008

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


  1. <?php
  2. $filesList = scandir( './images' );
  3. // tutaj używasz dowolnych funkcji sortujących tablicę, sort(), asort() itd.
  4. foreach( $filesList as $file )
  5. echo "filename: $file <br />";
  6. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 2.10.2025 - 17:09