faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

63 of 79 people (80%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

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

Mar 1st, 2009 08:48
Sarah Turner, healthy man, dman, Paolo Dente, Sharon Daniels, http://www.ttnr.org


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...
http://www.healthdothealth.com
http://www.healthxhealth.com
http://www.mesotheliomainmesothelioma.com
http://www.healthfirewall.com
http://www.flathealth.com
http://www.healthbodyguard.com
http://voyagevacances.blogtact.com/
http://rejseferie.blogtact.com/
http://flyvningertilschweiz.blogtact.com/
http://volssuisse.blogtact.com/
http://volsromeitalie.blogtact.com/
http://viajesvacaciones.blogtact.com/
http://reisenchina.blogtact.com/
http://flugeschweiz.blogtact.com/
http://resasemester.blogtact.com/
http://viaggivacanze.blogtact.com/
http://reisenurlaub.blogtact.com/
http://reizenvakanties.blogtact.com/
http://volisvizzera.blogtact.com/
http://gartenpflege.blogtact.com/
http://geschenkideeen.blogtact.com/
http://vluchtenromeitalie.blogtact.com/