Hi everyone -
Am getting the following error:
Parse error: syntax error, unexpected T_STRING in ... /index.php on line 11
Where the php file that's doing the reading of the directory is the index.php page in that directory.
Line 11 is the 'while loop' below. What I'm not understanding is that there are no quotes and no missing semicolons just before or on line 11. There just isn't that much.
Here's the code:
<?php
// name this file index.php and include it inside the directory you want the list from
// open the current directory
$dhandle = opendir('.');
// define an array to hold the files
$files = array();
if ($dhandle) {
** // loop through all of the files
** while (false !== ($fname = readdir($dhandle))) {
***** // if the file is not this file, and does not start with a '.' or '..',
***** // then store it for later display
***** if (($fname != '.') && ($fname != '..') &&
********* ($fname != basename($_SERVER['PHP_SELF']))) {
********* // store the filename
********* $files[] = (is_dir( "./$fname" )) ? "(Dir) {$fname}" : $fname;
******}
** }
** // close the directory
** closedir($dhandle);
}
// Now loop through the files, with a new line after each one
foreach( $files as $fname )
{
** echo "$fname \n";
}
?>
Any help would be gratefully appreciated. Thanks!
Lee