Home     My Faqts     Contributors     About     Help    

faqts : Computers : Programming : Languages : Php

FAQTs repaired & updated!
Thanks for your patience...
Entry Add Entry Alert - Edit this Entry

Did You Find This Entry Useful?

54 of 65 people (83%) answered Yes
Recently 6 of 10 people (60%) answered Yes

How can I list files in a specific directory and hyperlink to them?

Apr 26th, 2001 20:33

Paolo Dente, Sharon Daniels


This is a small function I used in a recent project, hope it might be 
useful.
function list_files($where)
{
	if(is_dir($where)) 
		{
		$thisdir = dir($where);
		while($entry=$thisdir->read()) 
			{
    			if(($entry!='.')&&($entry!='..'))
    				{
    				$result.= "<a href=$where/
$entry>$entry</a><br>'";
    				}
			}
		}
return $result;
}
You can probably make it recursive, but I didn't have (or see) the need 
to...



© 1999-2004 Synop Pty Ltd