Yup, the crazy colored beanie guy is right (thats why he has like 2,000+ posts) 😉
Here's so samlple code for you to play with:
// change to directory
$res = chdir($location);
// if chdir() successful
if ($res)
{
// get directory handle
$hook = dir($location);
// display location
echo "<b>Current path is $hook->path</b><br>";
// read directory and echo list
while ($file=$hook->read())
{
// dont output the dot or dotdot 😉
if ($file != "." && $file != "..")
{
echo "$file<br>";
}
}
// close directory
$hook->close();
and better yet..
<?
// get directory handle
$hook = opendir($location);
// read directory and echo list
while (($file = readdir($hook)) !== false)
{
if ($file != "." && $file != "..")
{
// set up full path
$path = $location . "/" . $file;
// check for directory
if (is_dir($path))
{
echo "<font color=Red>$file</font><br>";
}
else
{
echo "<font color=Green>$file</font><br>";
}
}
}
// close directory
closedir($hook);
?>
You can look over at www.devshed.com for more little gems like these 😉