Tell me please!

I have a list:

3. 1c4339449fbac9498fe422f4f5f1a5e4 - 3000 4. 3c7505a408e7c6d8c1e546ef2554bd86 - 3151 5. 4dac49f4d9ac0155c1a8941d67a064a0 - 2861 6. 673e67b0cae89166c3050adb6433ff7e - 3035 7. 85ae1ea5e2b82ed9f92fbdb21c30b63e - 3197 8. 9fc3128ff599b7a72682d0ad3f970e22 - 2767 9. a2442322c09760cd9685f659a0178709 - 3555 10. c18f517310ccd9c3824cd6787dbf8475 - 3213 11. d74f444905710381aeaf30c6d06410c9 - 2890 12. ea1f622e7fcb6db49ac80f920409bb44 - 3179 

This is the code that generates it:

 $path = 'storage'; $beforeDir = scandir('storage'); for ($i = 3; $i < count($beforeDir); $i++){ $f_info = stat("storage/$beforeDir[$i]"); $today = time(); $lastDay = date($f_info[mtime]); $countDay = $today - $lastDay; echo "<span style='text-align: left; margin-left: 50px; color: green;'>$i. <i>$beforeDir[$i]</i></span> - $countDay"."<br />"; $f_info = stat("storage/$beforeDir[$i]"); //echo "Время последнего изменения файла: ".date("d MYH:i:s" ,$f_info[mtime]) ."\n"; } 

In the list of file names, well, as is clear from the script, after the name I got some time, or rather a piece, how do I go through the list now and delete the file with the maximum value?

    1 answer 1

     // Получаем список всех файлов $files = glob( './test/*.*' ); //сортируем array_multisort( array_map( 'filemtime', $files ), SORT_NUMERIC, SORT_DESC, $files ); echo $files[0]; // самый старый файл 
    • Beautiful decision! - SilverIce
    • Friend, thank you so much :), but my sorting is in the reverse order, the opposite is the most recent file. - archisova
    • All figured out :) Changed SORT_DESC to SORT_ASC. Brilliant solution! Sorry I can’t reward, I’m green and young bye :( Just a big human thanks! - archisova