Re: Parsing a directory for specific files

From: Date: Fri, 10 Jan 2003 22:24:13 +0000
Subject: Re: Parsing a directory for specific files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-131198@lists.php.net to get a copy of this message
function get_file_list($dirName=".") { $list = array(); $handle = opendir($dirName); while (false !== ($file = readdir($handle))) { /* Omit the '.' and the '..' directories. */ if ((".."== $file) || ("."== $file)) continue; array_push($list, $file); } closedir($handle); return $list; } Then you have an array of the filenames. If you use rsort($array), the 5 first elements will be the 5 most recent ones. tommy "Dirk Van Lyrop" <Dirk.van.Lyrop@gmx.de> wrote in message news:3E1EED9A.5090300@gmx.de... > Hi, > > does anybody know how to solve the following task? > > I'd like to generate a dynamic page, which contents come from txt-files. > The files will be in a directory called content (from the page: > ../content) and they are labeled with date and (within one day) > increasing numbers, > e.g. 20030108-1.txt, 20030108-2.txt, 20030108-3.txt, 20030109-1.txt, > 20030110-1.txt, 20030110-2.txt > The script should parse the file names and get the most recent five ones! > > The text inside should be included in the page -> but this is not the > problem, the task mentioned above is the problem! > > Thx in advance for these who can deliever solutions or ideas! > > Dirk > >

« previous php.general (#131198) next »