Problem:
As time passes on new months the arsort only sorts by the first number because it takes it as a string. The dates in russia go in this format == date('d.m.Y',$timestamp).
I want to be able to sort it by dates and then display the dates on the screen in russian format yet again be able to read from folders.
I tried something like this
<?php
foreach($folders as $v) {
$newarr[] = strtotime($v);
}
arsort($newarr);
$folders = array();
foreach($newarr as $v) {
$folders[] = date('d.m.Y',$v);
}
// wont read from dir
?>
<?php
// show archives when page does load
// sort archives by date DESC
// first we build the array of current dirs in the report folder.
$folders = scandir('./reports');
array_shift($folders);
array_shift($folders);
arsort($folders);
$fc = 0;
foreach($folders as $value) {
if (is_dir('./reports/'.$value)) {
$folderarray[] = $value;
$filearray = scandir('./reports/'.$folderarray[$fc]);
foreach($folderarray as $folder => $key) {
foreach($filearray as $file) {
if(is_file('./reports/'.$key.'/'.$file)) {
$foldertreearray[$key][] = $file;
} // close if
} // close foreach file
} // close foreach folder
$fc++;
} // close if
}
if(isset($folders)) {
// we got the folders in $folders
echo "<table cellpadding='0' cellspacing='0' border='0' width='100%' style='padding:5px;'>";
foreach($folders as $folder) {
echo "<tr>";
echo "<td colspan='11'><div style='text-align:left;background-color:#CCCCCC;padding-left:10px;width:60px;'><b>$folder</b></div></td>";
echo "</tr>";
echo "<tr>";
$filesarray = scandir('./reports/'.$folder);
$cf = count($filesarray);
foreach($filesarray as $file) {
if (is_file('./reports/'.$folder.'/'.$file)) {
$arr1= str_split($file,1);
for($z=0;$z<=12;$z++) {
array_pop($arr1);
}
$x = implode('',$arr1);
echo "<td style='width:auto;background-color:#eeeeee;'><a href='./reports/$folder/$file' target='_blank'>".
$catsru[$x]
."</a></td>";
}
}
$cf = 13 - $cf;
for($x=1;$x<=$cf;$x++) {
echo "<td style='auto'></td>";
}
echo "</tr>";
}
echo "</table>";
}
?>