directory reading

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
santosh1234
Forum Newbie
Posts: 1
Joined: Tue Oct 10, 2006 4:29 am

directory reading

Post by santosh1234 »

How to read all the files in a directory.I want the output sorted according to the filedate
jito
Forum Commoner
Posts: 85
Joined: Sat Mar 25, 2006 4:32 am
Location: india

Post by jito »

use readdir() to read the content of a directory.
satheshf12000
Forum Commoner
Posts: 25
Joined: Mon Sep 04, 2006 5:38 pm

Post 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>";
?>
Post Reply