Take a look:
for ($i=1; $i<=$nr_of_pics; $i++) {
${'image_src' . $i} = $image_id.'_'.$i;
$img_array = imageSize(${'image_src' . $i}, $i, $category);
}
and here is the imageSize function (simplified):
$myarr = array();
$myarr['thumb_image_' . $nr . '_width'] = $thumb_width;
$myarr['thumb_image_' . $nr . '_height'] = $thumb_height;
$myarr['image_' . $nr . '_width'] = $width;
$myarr['image_' . $nr . '_height'] = $height;
return $myarr;
The function gets called and OWERWRITES the value of the $img_array inside the foor-loop, but I need it to ‘increment’ and add values after another in every loop.
So basically, it replaces its value every time it loops.
What should I do here?
Thanks
You’re overwriting
$img_arrayeach time through the loop. Try changingto
This will add an element to
$img_arrayinstead of replacing its value.