SameerMirza
03-30-2009, 02:46 PM
Hi all,
I have used the below script to read the directory struture in order to build the tree menu for my web.
<?php
$sub = ($_GET['dir']);
$path = 'enter/your/directory/here/';
$path = $path . "$sub";
$dh = opendir($path);
$i=1;
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != "..") {
if (substr($file, -4, -3) =="."){
echo "$i. $file <br />";
}else{
echo "$i. <a href='?dir=$sub/$file'>$file</a><br />";
}
$i++;
}
}
closedir($dh);
?>
This script read the directory structure in alpthabatical order but my requirement is to read on the basis of date created. It will be great if any one could tell me how to achieve it.
Regards,
Sameer.
I have used the below script to read the directory struture in order to build the tree menu for my web.
<?php
$sub = ($_GET['dir']);
$path = 'enter/your/directory/here/';
$path = $path . "$sub";
$dh = opendir($path);
$i=1;
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != "..") {
if (substr($file, -4, -3) =="."){
echo "$i. $file <br />";
}else{
echo "$i. <a href='?dir=$sub/$file'>$file</a><br />";
}
$i++;
}
}
closedir($dh);
?>
This script read the directory structure in alpthabatical order but my requirement is to read on the basis of date created. It will be great if any one could tell me how to achieve it.
Regards,
Sameer.