Array
(
[0] => Array
(
[id] => 1
[influencer_user_id] => 4
[content_data] => {"Reach":"300","Views":"320","Views through rate":"350","Shares":"350"}
)
[1] => Array
(
[id] => 2
[influencer_user_id] => 4
[content_data] => {"Reach":"100","Likes":"100","Views":"100"}
)
[2] => Array
(
[id] => 3
[influencer_user_id] => 5
[content_data] => {"Reach":"350"}
)
)
foreach($influencer_contents as $row){
$influencer_id = $row['influencer_user_id'];
}
if influencer_user_id is same inside the loop I need to sum the content_data. given example there are 3 array values influencer_user_id has to 4, I need to merge first two arrays( has same values) and need to make array count 2.
I tried like I created temporary array and I pushed the same influencer_id to temp_array like below but that is not working
if(!in_array($influencer_id, $array_temp)){
$array_temp[] = $influencer_id; }
i need output like this below,
Array
(
[0] => Array
(
[id] => 2
[influencer_user_id] => 4
[content_data] => {"Reach":"400","Likes":"100","Views":"100"}
)
[1] => Array
(
[id] => 3
[influencer_user_id] => 5
[content_data] => {"Reach":"350"}
)
)