I have an array structure like the following:
I would like to have the elements keys, bi, media and offer under biz_id. Like this:
biz_id
bi
media
offer
biz_id
...
My code is the following:
foreach ($premiumContent as $targets=>$target)
{
$finalResult[]["biz_id"] = $target->biz_id;
foreach ($target->media as $media)
{
switch ($media->type_id)
{
case '1':
$finalResult[]["info"] = $media->text;
break;
case '6':
$finalResult[]["bi"] = $media->url;
break;
case '4':
$mediaGroup[] = array('link' => $media->url, 'descript' => $media->text);
break;
case '3':
$offerGroup[] = array('link' => $media->url, 'descript' => $media->text);
break;
default:
echo '';
}
}
$finalResult[]["media"] = $mediaGroup;
$finalResult[]["offer"] = $offerGroup;
}
return $finalResult;
What can I do to group the keys underneath biz_id?
Thanks for the recommendations.