I need help, how to sort the code below, by file date?.
$dir2 = "flash/$plk/img";
$plks2 = scandir($dir2);
$plkss2 = array_diff($plks2, array('.', '..'));
foreach ($plkss2 as $plk2) {
echo '<img data-src="flash/'. str_replace('+', '%20', urlencode($plk)) .'/img/' . $plk2 . '" alt="" class="img-responsive lazyload">';
}
This should work for you:
(I just get all files of the directory with
glob()
, then I sort the array withusort()
, where I usefilemtime()
to compare the last modification and the I loop through every file with the foreach loop)here you go