I've been playing about more and now I have the following code:
<?
error_reporting(E_ALL);
ini_set('display_errors', true);
function getDirectory($path = '.', $ignore = '') {
$dirTree = array ();
$dirTreeTemp = array ();
$fileDate = array ();
$ignore[] = '.';
$ignore[] = '..';
$dh = @opendir($path);
while (false !== ($file = readdir($dh))) {
if (!in_array($file, $ignore)) {
if (!is_dir("$path/$file")) {
$dirTree["$path"][] = $file;
$fileDate["$file"][] = date ("d/m/Y",
filemtime("$path/$file"));
} else {
$dirTreeTemp = getDirectory("$path/$file", $ignore);
if (is_array($dirTreeTemp))$dirTree =
array_merge($dirTree, $dirTreeTemp, $fileDate);
}
}
}
closedir($dh);
return $dirTree;
}
$ignore = array('.htaccess', 'Thumbs.db', 'index.php');
$dirTree = getDirectory('.', $ignore);
getdirectory('.');
echo "Gatwick Tender Documents\n";
foreach( $dirTree as $key => $folder ){
echo "\n"; //Don't need folders as they're shown with the files
foreach( $folder as $file){
echo str_replace("./", "", $key) . "\t" . $file . "\t\n"; //Pad
out with a tab for easy import into excel
}
}
print_r($dirTree); //Just using this for debugging
?>
The output is fine for the paths and filenames but I still can't get
the dates showing. It's getting the correct date for some but not all.
I did something else earlier and found that all the dates were
01/01/1970 but at least there was a date for every file but can't
remember how I go there!
Here is a sample output result:
Gatwick Tender Documents
. 9216_100_REV_V1.0_bound.dwg
Tender Docs BAA Works Terms v1.1 (22.05.08).pdf
Tender Docs Contents of Volumes 1 and 2.pdf
Tender Docs Cover Letter and Instructions.doc
Tender Docs Form of Tender.doc
Tender Docs/Health and Safety Questionnaire NT Baggage Tender
Questionaire rev2.xls
BAA Works Terms v1.1 (22.05.08).pdf 29/07/2009
Contents of Volumes 1 and 2.pdf 29/07/2009
Cover Letter and Instructions.doc 29/07/2009
Form of Tender.doc 29/07/2009
Tender Docs/NTB BH Lighting 3J-B-1 PIR.xls
Tender Docs/NTB BH Lighting 3J-B-2B PIR.xls
Tender Docs/NTB BH Lighting 3J-B-2R PIR.xls
Tender Docs/NTB BH Lighting 3J-B-3R PIR.xls
Tender Docs/NTB BH Lighting 3J-D PIR.xls
Tender Docs/NTB BH Lighting 4G-G PIR.xls
Tender Docs/NTB BH Lighting 4J-B-1B PIR.xls
Tender Docs/NTB BH Lighting 4J-B-1R PIR.xls
Tender Docs/NTB BH Lighting 4J-B-2B PIR.xls
Tender Docs/NTB BH Lighting 4J-B-2R PIR.xls
Tender Docs/NTB BH Lighting 4J-B-4 PIR.xls
Tender Docs/NTB BH Lighting 5G-G PIR.xls
Can anyone shed any light on it?
I'm about to admit defeat!
Thanks in advance and I'm not being lazy - I really am trying!!! :(
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php