Jamesking56 Posted January 22, 2008 Share Posted January 22, 2008 How do I make PHP Generate an Index page showing all the files in the directory and linking to them?and if I add it changes?? Link to comment Share on other sites More sharing options...
Jamesking56 Posted January 22, 2008 Author Share Posted January 22, 2008 When I use glob(); it comes up as just"Array" Link to comment Share on other sites More sharing options...
Matpatnik Posted January 22, 2008 Share Posted January 22, 2008 you can use this function: // show inside of a directoryfunction intofolder($directory) { $show_file = ''; if ($handle = opendir($directory)) { $show_file = 'Directory handle: $handle<br />'. 'File:<br />'; while (false !== ($file = readdir($handle))) { $show_file .= $file .'<br />'; } closedir($handle); } return $show_file;} Link to comment Share on other sites More sharing options...
justsomeguy Posted January 23, 2008 Share Posted January 23, 2008 When I use glob(); it comes up as just"Array"You're not using glob correctly.$files = glob("/path/to/dir/*.*");foreach($files as $file){ echo $file . "<br>";}foreach ($files as $file){ echo "<a href=\"{$file}\">{$file}</a><br>";} Link to comment Share on other sites More sharing options...
Synook Posted January 23, 2008 Share Posted January 23, 2008 Glob takes a single argument which specifies the filename and path, and a second optional one specifying what sort of files to return. It accepts the wildcard character *, and a limited form of regular expressions. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.