body{
background:grey;
}
td{
border:1px solid orange;
}
<?php
class Foo {
public $mydir = 'foxfoxfox/';
public function inverse(){
$arr = [];
$output = scandir($this->mydir);
for($i=0;$i<count($output);$i++){
if($output[$i]=='.' || $output[$i]=='..'){
null;
}else{
$arr[$output[$i]] = filemtime($this->mydir.$output[$i]);
}
}
return $arr;
}
}
$bar = new Foo();
$xua = $bar->inverse();
?>
<form method="get" action="">
<select name="newest_latest">
<option value="newest">newest</option>
<option value="latest">latest</option>
</select>
<input type="submit"/>
</form>
<?php
$newest_latest = $_GET['newest_latest'] ?? 'newest';
if($newest_latest==='latest'){
asort($xua);
}else{
arsort($xua);
}
?>
<table>
<?php
$iterator=0;
$cl = 0;
foreach($xua as $key_arr => $value_arr){
if($iterator%5==0) {
$new_tag_op = '<tr>';
$new_tag_cl = null;
}else{
$new_tag_op = null;
$cl++;
}
if($cl==4){
$new_tag_cl = '</tr>';
$cl=0;
}
$iterator++;
echo "{$new_tag_op} <td><img src=\"{$bar->mydir}/{$key_arr}\"/></td>";
$dateTime_x = date('F d Y H:i:s',$value_arr);
echo "<td>{$dateTime_x}</td>{$new_tag_cl}";
}
?>
</table>
Wklej ten kod do swojego edytora w takiej kolejności w jakiej podałem.