At 23:28 10-2-2003, you wrote:
G'day all

I've been trying for a day or so to get a script to traverse all the levels
of a directory.
did you see the first user comment on http://nl.php.net/manual/nl/ref.dir.php ? may help!

With help from list archives and web sites I've come up
with this:

<?php

$the_array = Array();
$thedir = "/Users/kim/test/";
$handle = opendir($thedir);

while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != ".DS_Store")
{
$the_array[] =  $thedir . $file;
}
}
closedir($handle);

foreach ($the_array as $i)
{
$fileinfo = fopen(($i), "r") OR die("Failed to open file $i");
$thedata = fread($fileinfo, filesize($i));
fclose($fileinfo);

echo "$i $thedata<br>";
}

?>

I've read lots f stuff about "if (is_dir($blah)" but I get a bit lost with
the navigation after that (I'm _real_ new to *nix as well).  Could someone
please help as to how it would fit into my script?

Cheers and thanks

kim


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to