I am trying to show images on my website with php usort, so the new images should be at the top and the oldest at the bottom. I tried to use usort, but it is not working and the images are still displayed the opposite way, the old ones are at the top and the new ones are at the bottom. Is something wrong with my code, or why is it happening? (I read all of the topics here at stackoverflow that have something in common, but I did not figured out what is wrong.)
I use this code:
$folder_path = 'posters/';
$num_files = glob($folder_path . "*.{JPG,jpg,gif,png,bmp}", GLOB_BRACE);
usort( $num_files, function( $a, $b ) { return filemtime($a) < filemtime($b); } );
$folder = opendir($folder_path);