Basically it says this:
$item is a list of all items currently in the directory that is open (or called thorugh readdir()).
Then, substr($item, 0, 1) looks for the FIRST character to be a ".". If so, it is either: . or .. meaning that it is either the current directory, or the link to the parent directory.
So if it's not one of those, then it lists it.
<?php
//list the sub directories
$dp = '.';
echo '<p style="font-weight: bold;">Contents Of: <i>'.$dp.'</i></p>
<p class="margin: 0; padding: 0; color: #090;">+ '.$dp.'</p>';
$handle = opendir($dp);
while ($item = readdir($handle))
{
if ((substr($item, 0, 1) != '.'))
{
if(is_dir($item))
{
$handle2 = opendir('./'.$item);
echo '<p style="margin: 0; padding: 0; color: #090;">| + <b>'.$item.'</b></p>';
while($item2 = readdir($handle2))
{
if ((substr($item2, 0, 1) != '.'))
{
echo '<p style="margin: 0; padding: 0;">| |-- '.$item2.'</p>';
}
}
closedir($handle2);
}
else
{
echo '<p style="margin: 0; padding: 0;">| '.$item.'</p>';
}
}
}
closedir($handle);
?>
Hope that helps.
That outputs:
Contents Of: .
+ .
| + Local_Hero
| |-- header_gen.php
| |-- index.php
| |-- replacement.js
| |-- fonts
| |-- cache
| |-- error_log
| |-- test.php
| threat_level.php
| + adityakonda
| |-- functions.phps
| |-- userview.phps
| mime_type.jpg
| readdir.php
~Brett