Zend - The PHP Company




Files and Directories

Add Code


Directory Index'r  

Type: code fragment
Added by: blue7
Entered: 26/08/2001
Last modified: 08/12/2000
Rating: *** (9 votes)
Views: 16519
function that reads directory content and returns the result as links to every file in the directory. toss it into any directory as index.php and get a list of links to every file


<? 
/******************************************************************** 
*    function that reads directory content and 
*    returns the result as links to every file in the directory
*    
*    toss it into any directory and get a list of links to every file
*
*       This program is free software licensed under the 
*       GNU General Public License (GPL). 

*********************************************************************/ 
function directory($result) { 
    
     
$handle=opendir("."); 
     while (
$file readdir($handle)) { 
     if (
$file == "." || $file == "..") { } else { print "<a href=$file>$file</a><br>n"; }
      
     } 
     
closedir($handle); 

return 
$result



?> 
<b>Select the file you want to go to:</b>
<p>
<? 
echo directory($result); 
?> 


Usage Example




Rate This Script





Search



This Category All Categories