Page 1 of 1

directory reading

Posted: Tue Oct 10, 2006 4:36 am
by santosh1234
How to read all the files in a directory.I want the output sorted according to the filedate

Posted: Tue Oct 10, 2006 4:42 am
by jito
use readdir() to read the content of a directory.

Posted: Tue Oct 10, 2006 6:56 am
by satheshf12000
I think this is what u need..

Code: Select all

<?php
		$handle = opendir("yourpath");
		while ($file = readdir($handle))
		{
			if($file != "." && $file != "..")   // to omit . and .. from the directory
				$gallery[] = $file;
		}
			
		sort($gallery);
		
		foreach($gallery as $value)
			echo "$value<br>";
?>