Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Sortowanie wg daty, co zrobic zeby zdjecia był sortowane wg daty?
AdiosAmigos
post
Post #1





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 1.05.2009

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


Witam, co zrobic zeby zdjecia był sortowane wg daty dodania (od najnowszej)
daje kod:

CODE


$dir = 'thumbs';
$imagesExtensions = array('jpg', 'jpeg', 'gif', 'png', 'bmp');
$files = scandir($dir);
foreach($files AS $file) {
$fileinfo = pathinfo($file);
if(is_file($dir.'/'.$file) AND in_array($fileinfo['extension'], $imagesExtensions)) {
echo '<img src="'.$dir.'/'.$file.'" alt="" />';
}
}

Go to the top of the page
+Quote Post
nexis
post
Post #2





Grupa: Zarejestrowani
Postów: 1 012
Pomógł: 109
Dołączył: 26.09.2003
Skąd: nexis.pl

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


filectime" title="Zobacz w manualu PHP" target="_manual

  1. <?php
  2. // Ścieżka
  3. $dir   = './';
  4. // Rozszerzenia
  5. $ext   = array('jpg', 'jpeg', 'gif', 'png', 'bmp');
  6. // Pliki w folderze
  7. $files = scandir($dir);
  8. // Lista na pliki
  9. $list  = array();
  10. foreach($files AS $file) {
  11.    $file = pathinfo($file);
  12.    if (in_array($file['extension'], $ext)) {
  13.        $list[$file['basename']] = filectime($file['basename']);
  14.    }
  15. }
  16. // Sortowanie według daty utworzenia
  17. asort($list);
  18. // Wyświetlanie
  19. foreach ($list as $element) {
  20.    printf('<img src="%s%s" alt="" />', $dir, $element);
  21. }
  22. ?>
Go to the top of the page
+Quote Post
AdiosAmigos
post
Post #3





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 1.05.2009

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


edit:
wywietla sie na stronie

Warning: filectime() [function.filectime]: stat failed for nazwapiku.jpg in /home/dajfoto/domains/strona.pl/public_html/galeria.php on line 13

Ten post edytował AdiosAmigos 21.05.2009, 19:08:09
Go to the top of the page
+Quote Post
erix
post
Post #4





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




No to znaczy, że ścieżka do pliku jest nie taka, jaka być powinna albo brak uprawnień.
Go to the top of the page
+Quote Post

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: 23.08.2025 - 12:54