Re: Create array from directory

From: Date: Fri, 11 Apr 2003 12:10:42 +0000
Subject: Re: Create array from directory
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143485@lists.php.net to get a copy of this message
> From: Chris Blake <cblake@pbpc.co.za> > > Greetings learned PHP(eople), > > I wish to create an array of images from a specific directory. > On PHP.net I searched using "arrays from directories" and got taken thru > to here : > > http://marc.theaimsgroup.com/?l=php-general&r=1&w=2&q=b&s=%22arrays+from+direc > tories%22 > > Which didn`t help ! > > I also went to the news server on PHP but it tells me "news cannot be > found". (?) > > Where can I access the archives to search through ? > I know this info was sent to me in my welcome email, but that has gone > AWOL. Searching for "arrays from directories" here returns a bunch of results: <http://marc.theaimsgroup.com/?l=php-general> And here's how I do it: $current_dir = $DOCUMENT_ROOT . "/" . $dir_name . "/"; $dir = @opendir($current_dir); $gallery = array(); while ($file = readdir($dir)) { $filepath = $current_dir . $file; if ($file != '.' && $file != '..' && is_dir($filepath)) { array_push($gallery, $file); } } closedir($dir); sort($gallery); reset($gallery); -- Lowell Allen

« previous php.general (#143485) next »