Re: creating a text file

From: Date: Fri, 11 Apr 2003 15:45:09 +0000
Subject: Re: creating a text file
Groups: php.general 
Request: Send a blank email to php-general+get-143531@lists.php.net to get a copy of this message
I have run this script (see below) with the proper directory and I can pull every value out of the array except for the 0 value. When I print_r the entire array this is what I get: Array ( [] => 1.jpg [1] => 10.jpg [2] => 11.jpg [3] => 12.jpg [4] => 13.jpg [5] => 14.jpg [6] => 15.jpg [7] => 16.jpg [8] => 2.jpg [9] => 3.jpg [10] => 4.jpg [11] => 5.jpg [12] => 6.jpg [13] => 7.jpg [14] => 8.jpg [15] => 9.jpg ) and when I print $jpegsArray[$ctr] I get nothing. Why is it doing this and how can I fix it?
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 ++; } } } }
_________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus

« previous php.general (#143531) next »