PHP Script
<?php
echo '<ul class="DirView"><li><a href="#">Recently Used<span>28</span></a></li>';
$path = "../Desktop/IMG/BananzaNews/";
$dir = new DirectoryIterator($path);
foreach ($dir as $fileinfo) {
if ($fileinfo->isDir() && !$fileinfo->isDot()) {
$subPath = $path.$fileinfo->getFilename();
$subDir = new DirectoryIterator($subPath);
$count = count(glob($subPath. "/*.*"));
echo '<li><a href="#">'.$fileinfo->getFilename().'<span>'.$count.'</span></a><ul class="sub-menu">';
foreach ($subDir as $subPath) {
if ($subPath->isDir() && !$subPath->isDot()) {
$file = $subPath->getFilename();
$fullPath = $path.$subPath.'/'.$file.'/*.*';
$inFullPath = count(glob($fullPath. '/*.*'));
echo '<li><a href="#">'.$file.'<span>44</span></a><li>';
}
}
echo '</ul></li>';
}
}
echo '</ul>';
?>
Result
The Problem
Only ignoring the 'recently used' category, the rest fully reads my directories of which are duplicated for testing purposes. As you can see, each sub_category has 44 files inside.
What I now want to do is count the total files (44 + 44) and display them on their parent category (88) however as I've already written this to my page, is this possible or is a bit of re-scripting needed?
';