I have a php file which displays videos from a folder named gallery but the problem is it displays videos in alphabetical order and I want the videos to be displayed by date i.e newest first. What do I need to add in my php code?
Here's the code:
<div id="vid-gallery">
<?php
$exten = '.mp4';
$dir = __DIR__ . DIRECTORY_SEPARATOR . "gallery" . DIRECTORY_SEPARATOR;
$videos = glob("$dir*.{mp4}", GLOB_BRACE);
$alt = glob("$dir*.{webm,mp4,ogg}", GLOB_BRACE);
if (count($videos) > 0) { foreach ($videos as $vid) {
$base = basename($vid,'.mp4');
printf("<div class='vi'><video src='gallery/%s' id='basename($vid,'.mp4')' loop='loop'></video>", rawurlencode(basename($vid)));
echo "<div class='title'>".basename($vid,'.mp4')."</div></div>";
}}
?>
</div>
When answering please tell where should the answered code be put.
You can check example the here:
And please it isn't the same as sorting arrays, it's different.
Thanks in advance:)