Alright, I've come across something that I'm having trouble with. I'm -attempting- to create a "Source Code Viewer". Now I googled one, and found it, yet I'm having some trouble making sense of it.
PHP Code:
function getDirList ($dirName) { $d = dir($dirName); while($entry = $d->read()) { if ($entry != "." && $entry != "..") { if (is_dir($dirName."/".$entry)) { getDirList($dirName."/".$entry); } else { if ( (ereg('\.php$', $entry)) && (!ereg('index\.php$', $entry)) ){ echo "<a href=./?filename=".$dirName."/".$entry.">".$dirName."/".$entry."</a><br>\n"; }
If you wouldn't mind, i want to ensure that I'm understanding the various portions of this script. For the first line: "function getDirList ($dirName) {" That would typically, in english, be: "Get Directory List called 'dirName'"
Following that, the second line pertains to setting $d to the directory name. However, I don't understand the third line. I know the "while" function, but the $entry = $d->read()) { I dont understand. Any clarification would be appreciated.
|