Have code that right now creates and array of a directory that has text files and gets their modified date and then sorts descending then slices and echos each individually with other parameters.
I am changing it to get the files in a directory and sort by filename which are numeric and then I want it sorted descending then sliced then echoed.
$files_listed = array();
foreach (glob('dir/*.txt') as $quip) {
$files_listed[filemtime($quip)] = $quip;
}
krsort($files_listed);
$master_arc = array_slice($files_listed, 0, 5, true);
// array
foreach($master_arc as $step) {
$arc = file($step, FILE_IGNORE_NEW_LINES);
// print
include 'echo.php';
}
I tried scandir and nothing showed up
$files_listed = array();
$dir = 'dir/';
$files_listed = scandir($dir, 1);
$master_arc = array_slice($files_listed, 0, 5, true);
// array
foreach($master_arc as $step) {
$arc = file($step, FILE_IGNORE_NEW_LINES);
// print
include 'echo.php';
}
I tried just removing filemtime and it also failed so I am lost.
$files_listed = array();
foreach (glob('dir/*.txt') as $quip) {
$files_listed = $quip;
}
arsort($files_listed);
$master_arc = array_slice($files_listed, 0, 5, true);
// array
foreach($master_arc as $step) {
$arc = file($step, FILE_IGNORE_NEW_LINES);
// print
include 'echo.php';
}