Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di miki.
    Registrato dal
    Oct 2004
    Messaggi
    1,918

    Selezionare file a seconda della data

    io ho in una directory delle foto con il nome del file mmggyy.jpg

    io prendo tutti i nomi dei file così

    Codice PHP:
    $handle       opendir($image_path);

                  while (
    $file readdir($handle)) {
                      
    $image_data[] = $file;
                  }
                  
    closedir($handle); 
    e poi tramite un for stampo a video tutte le immagini.

    Il problema sta nel fatto che io vorrei che facesse questa cosa per tutte le immagini contenute nella directory che hanno data da oggi indietro. Ad esempio l'immagine con data 121205 anche se nella directory, non me la mettesse nell'array.
    Ho provato a mettere un if prima di $image_data[] = $file; ma non cambia niente

    Codice PHP:

                      $month 
    substr($file,0,1);
                      
    $day substr($file,2,3);
                      
    $year substr($file,4,5);
                      
    $date_image mktime(0,0,0,$month,$day,$year);
                      
    $date_now time();
                          if(
    date_image <= $date_now);{
                              
    $image_data[] = $file;
                          }
                      } 
    You cannot discover new oceans unless you have the courage to lose sight of the shore

    Caro Dio, quando nelle preghiere ti chiedevo di far morire quel pedofilo truccato, liftato,mentalmente disturbato e di colore indefinibile, non intendevo Michael Jackson.

  2. #2
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    codice:
    $image_path="prova";
    $image_data=array();
    $handle = opendir($image_path);
    while ($file = readdir($handle)) {
    	if ($file != "." && $file != ".."){
    		$temp=explode(".",$file);
    		$temp="20".substr( $temp[0],4,2).substr( $temp[0],0,2).substr( $temp[0],2,2);
    		if ($temp < date("Ymd"))
    			$image_data[] = $file;
    	}
    }
    closedir($handle);
    print_r($image_data);
    think simple think ringo

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.