Im using this code to get the most recent file created:
<?php
$files = glob($siteRoot.'/dir/*/*.php');
$files = array_combine($files, array_map('filectime', $files));
arsort($files);
echo key($files);
?>
How can I enhance this to get the last 3 files created, or what ever number I need? Any help would be appreciated. Thanks!
This should work for you:
Just take an array_slice()
from your array:
$slice = array_slice($files, 0, 3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With