This script scans the directory 'uploads' and list their subfolders. All subfolders has this structure
YYYY-MM-DD_hh:mm:ss_text
for example
- 2013-03-18_23:59:59_cam1
- 2013-03-18_09:22:12_cam1
- 2013-03-17_19:05:02_cam2
- 2013-03-17_12:30:28_cam4
I want to make separate UL TAGS on new day (position 9 and 10). Something like
<ul><li>2013-03-18_23:59:59_cam1</li><li>2013-03-18_09:22:12_cam1</li></ul>
<ul><li>2013-03-17_19:05:02_cam2</li><li>2013-03-17_12:30:28_cam4</li></ul>
I have no idea how to compare position 9 and 10 in a foreach statement and ask for help! Thank you!
Here is my script
<?php
// Name of directory
$directory = "uploads/";
$action=opendir($directory);
while($read=readdir($action)){
$dat_array[] = $read;
}
//sort array reverse
rsort($dat_array);
foreach($dat_array as $read) {
if(!preg_match("!(\.|\..)$!", $read)){
echo '<ul><li><a href="dir.php?id='.$read.'"><span>'.$read.'</span><span></span></a></li></ul>';
}
}
?>