Board Logo

Images in differents directories
klod - 5/5/2008 at 09:07 PM

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 :

Code:
$s_path = 'img/';

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 - 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, "ntt'$s_path$s_file'");
}
closedir($h_dir);
}
sort($a_images);
echo join(',', $a_images);


klod - 5/6/2008 at 06:55 PM

Hi,

Thanks, it's working very well :)


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/