Sayfalar

31 Ekim 2017 Salı

php sort change time of file

      $rootPath = "your path";
        $files= scandir($rootPath);
        $i=0;
        foreach ($files as $file){

            if($file != '.' and $file != '..')
            {
                $myfiles[$i]["name"]= $file;
                $myfiles[$i]["date"]=date ("d.m.Y H:i:s", filectime ('file path'.'/'.$file));
                $i++;

            }
        }
     
      $temp_array = array();
        foreach ($myfiles as $key => $row)
        {
            $temp_array[$key] = $row['date'];
        }
        array_multisort($temp_array, SORT_DESC, $myfiles); // result return $myfiles

Hiç yorum yok:

Yorum Gönder