Jump to content

Linking to all files in a directory


Phenomena

Recommended Posts

Ok so what I'm trying to do is set up a directory that will contain a bunch of different web pages and have any web page in that one directory linked on the nav.php  automatically. Lets say I have 3 files in my stuff/ directory, named file1.php, file2.php and file3.php.

 

In the nav.php I want a script that will generate this html for every page

 

<a href="/stuff/$file">$name</a>

 

where $file is the file name in the directory, and $name is a variable defined within the file its self.

Link to comment
https://forums.phpfreaks.com/topic/58596-linking-to-all-files-in-a-directory/
Share on other sites

Well, generating a list of all the files in the directory is reasonably straight forward. Take a look at the examples on the php website for readdir()

 

You could then use the fread() function to get the contents of each file and find your name.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.