Thursday, February 6, 2014

[PHP][Resolved] array_merge() [function.array-merge]: Argument #1 is not an array

I am using godaddy's hosting and someday the array_merge methods doesn't work for me:
The errors may be occured After PHP5 Upgrade:

From
array_merge($image_detail[0], $image_detail[$i]);
To
array_merge((array)$image_detail[0], (array)$image_detail[$i]);

This is my case for your reference:
From:
for ($i=0; $i < $photo_count ; $i++){
     if (!empty($data['photos'][$i]['thumb_url']) ){
         $image_detail[$i] = array(array('id' => 'p_'.$i,
                'original_url' => $data['photos'][$i]['original_url'],
                'thumb_url' => $data['photos'][$i]['thumb_url'],
                'itag_overview' => $data['photos'][$i]['itag_overview'],
                'itag_seed' => $data['photos'][$i]['itag_seed']));
         array_merge($image_detail[0], $image_detail[$i]);
       }else{
         echo "no Image";
      }
 }//EOF for
To:
for ($i=0; $i < $photo_count ; $i++){
     if (!empty($data['photos'][$i]['thumb_url']) ){
         $image_detail[$i] = array(array('id' => 'p_'.$i,
                'original_url' => $data['photos'][$i]['original_url'],
                'thumb_url' => $data['photos'][$i]['thumb_url'],
                'itag_overview' => $data['photos'][$i]['itag_overview'],
                'itag_seed' => $data['photos'][$i]['itag_seed']));
         array_merge((array)$image_detail[0], (array)$image_detail[$i]);
       }else{
         echo "no Image";
      }
 }//EOF for

Refernce:
http://forums.oscommerce.com/topic/266601-warning-array-merge-functionarray-merge-argument-1-is-not-an-array-in-homebabzonbopublic-htmladmincustomersphp-on-line-733/

No comments :

Post a Comment