Re: creating a text file

From: Date: Thu, 10 Apr 2003 17:06:13 +0000
Subject: Re: creating a text file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143362@lists.php.net to get a copy of this message
At 4/10/2003 02:52 PM, Tyler Durdin wrote:
Is there a way to make php create a text file that lists contents of a directory? This
is what I use from shell: csh -c "ls *jpg > list.photos"
This will give you an array called jpegsArray that will list every file with a .jpg extension in it. If you want the entire directory, just take the conditional out. Make sure to change your directory before running this. $location = "/usr/local/www/htdocs/images/"; if ($dir = @opendir($location)) { while (($file = readdir($dir)) !== false) { if (strstr($file,".") && $file!="." && $file!="..") { $thisFileArray = explode(".",strtolower($file)); if ($thisFileArray[1]=="jpg") { $jpegsArray[$ctr] = $file; $ctr ++; } } } } -- S. Keller UI Engineer The Health TV Channel, Inc. (a non - profit organization) 3820 Lake Otis Pkwy. Anchorage, AK 99508 907.770.6200 ext.220 907.336.6205 (fax) Email: skeller@healthtvchannel.org Web: www.healthtvchannel.org

« previous php.general (#143362) next »