klod
Junior Member
Posts: 2
Registered: 5/5/2008
Member Is Offline
|
| posted on 5/5/2008 at 09:07 PM |
|
|
Images in differents directories
Hi,
Thanks for your script. I think that I will use the php one (4th in your examples). Just a question on scanning differents directories.
The script says :
I try to amend it in following ways, but it does not work
| Code: | | $s_path
= array ('img1/', 'img2/'); |
I'm not a PHP expert, so if you have a solution, it will be great :)
Yours,
|
|
|
tigra
Administrator
Posts: 1912
Registered: 6/17/2002
Location: US, CO
Member Is Offline
|
| posted on 5/6/2008 at 02:05 PM |
|
|
if you're replacing the string with the array of strings then you should add the loop to make script go through all the elements of the array.
Here's the modified code from the top of the head (not tested):
| Code: |
$a_paths = array ('img1/', 'img2/');
$a_types = array ('jpg', 'gif', 'jpeg', 'png');
$a_images = array ();
foreach ($a_paths as $s_path) {
$h_dir = opendir($s_path);
while ($s_file = readdir($h_dir)) {
$s_type = strtolower(substr(strrchr($s_file, '.'), 1));
if (in_array($s_type, $a_types))
array_push($a_images, "\n\t\t'$s_path$s_file'");
}
closedir($h_dir);
}
sort($a_images);
echo join(',', $a_images);
|
|
|
|
klod
Junior Member
Posts: 2
Registered: 5/5/2008
Member Is Offline
|
| posted on 5/6/2008 at 06:55 PM |
|
|
Hi,
Thanks, it's working very well :)
|
|
|
|