user539493
user539493

Reputation: 159

How to create this type of index.php ? (Sitemap ?)

I have a folder with tons of .html files

My folder is root/searches

Now i have tons of files in "searches" folder as "root/searches/example.html".I want to create an index.html for this folder as "root/searches/index.html"

Now in this index.html

I want to hyper link all the files in this folder . Basically like a sitemap.

NOTE: New files are created each second in this folder.So i can't do it manually.

This is my folder : http://www.searchr.us/web-search/

Can anyone give me the script or HTML for this ? Thanks

Upvotes: 0

Views: 185

Answers (1)

Matt Lowden
Matt Lowden

Reputation: 2616

Is this what you are after?

$dir = '../dir';
$files = scandir($dir);

foreach($files as $file){
    if($file == '.' || $file == '..' || !is_file($dir.'/'.$file)){
        continue;
    }
    print "<a href=\"$file\">$file</a><br />";
}

This'll run through all of the files in the folder and print a link to them.

Upvotes: 3

Related Questions