Can't get this array working, new to arrays
<p>I want the array ($img_array) to increase every time it's looped, but it wont.
The length of the array is 0 when I echo it 'echo count(array);'</p>

<pre><code>function imageSize($name, $nr, $category, $myarr){
    $path = 'ad_images/'.$category.'/'.$name.'.jpg';
    $path_thumb = 'ad_images/'.$category.'/thumbs/'.$name.'.jpg';
    list($width, $height) = getimagesize($path);
    list($thumb_width, $thumb_height) = getimagesize($path_thumb);
    //$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;

}

    if ($nr_of_pics!=0){
     $image_id = end( explode( '_', $ad_id ) );
     $img_array = array();
    for ($i=1; $i&lt;=$nr_of_pics; $i++) {
     ${'image_src' . $i} = $image_id.'_'.$i;
     imageSize(${'image_src' . $i}, $i, $category, $img_array);
     }
    }
    echo count($img_array);
    echo $img_array['image_3_width'];
</code></pre>

<p>What is wrong?</p>

<p>ALSO, when I echo the $img_array element as you can see, it can't find it, says undefined index...
BUT when I echo the element from INSIDE the function, it will work!</p>

<p>If you need more input let me know and I will update this Q.</p>

<p>Thanks</p>
