note 10437 added to dir

From: Date: Wed, 03 Jan 2001 20:53:57 +0000
Subject: note 10437 added to dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-9348@lists.php.net to get a copy of this message
Well, This got denied from Freshmeat, but I know it will be useful here. This will generate HTML links for anything in a Direcory. <html> <body bgcolor="#000000" link="#6600cc" vlink="#6600CC" alink="#6600CC" text="#FFFFFF"> <font face="Arial,Helvetica" size="2" color="#6600CC"> <b> <center> <p>&nbsp;</p> <?php $d = dir("./"); $path = "SET THIS TO THE TOP DIRECTORY"; $dir = getcwd(); list($crap, $dir) = split("$path/", $dir); while($entry=$d->read()) { $url = ("$dir" . "$entry"); $url = ereg_replace(" ", "%20", $url); if ($entry != "." && $entry != ".." && $entry != "index.php") { echo "<a href=\"$url\""."target=_parent>".$entry."</a><br>\n"; }} $d->close(); ?> </center> </b> </font> </body> </html> The only catch is you need to set $path to a starting dir, but you can copy the index.php to any subdirs without changing the $path. http://www.php.net/manual/class.dir.php

« previous php.notes (#9348) next »