Forum Moderators: coopster

Message Too Old, No Replies

Listing information about all folders in directory

         

Skier88

12:02 am on Nov 3, 2009 (gmt 0)

10+ Year Member



I'm trying to create a page that automatically loads links to the index pages of its subfolders. I have written this:

$dir = opendir(".");
while($file = readdir($dir))
if(strrpos($file,".")===false)
echo("<a href='$file'>$file</a><br />");

Which successfully finds all the folders I want to display, and displays links to them.

What I want to do is change the content of the link (currently the folder name) to the title of the page (not the <title> element in the head, but the first <h1> element in the body). Obviously I cannot load all of the pages. My priorities are for it to be 1) fast/efficient, 2) automatic, and 3) space efficient. I am willing to introduce name/id tags, but I would like to avoid creating an file listing the folders for the simple reason that it would not automatically and instantaneously update.

Any suggestions?

Skier88

12:04 am on Nov 3, 2009 (gmt 0)

10+ Year Member



On second thought, just getting the <title> elements in the head of each page would be OK but not preferable, as they could be edited to yield the desired result.

Skier88

1:26 am on Nov 3, 2009 (gmt 0)

10+ Year Member



I found the answer. Since the first line was a PHP function including the page title, I could simply use fgets and display the appropriate substring.

TheMadScientist

10:16 am on Nov 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Glad we all got to help.
That's what we're here for.
Situation like these...

LOL. Glad you got it working.

Skier88

3:57 pm on Nov 3, 2009 (gmt 0)

10+ Year Member



lol.. yeah, well thanks for reading anyway. I probably should have looked a bit longer before asking for help.