I must combine or implode subarray values if the product will be the same for any company.
Expected output should be like:
0 =>
array (
'company' => '1,6'
'product' => 5,
),
My Array is:
array (
0 =>
array (
'company' => 1,
'product' => 5,
),
1 =>
array (
'company' => 2,
'product' => 4,
),
2 =>
array (
'company' => 6,
'product' => 5,
),
3 =>
array (
'company' => 2,
'product' => 3,
),
)
My code is:
foreach($prSuppliers as $key=>$val){
if($prSuppliers[$key]['company_master_id']==$val['company_master_id']){
$contactemaileach = $val['company_master_id'];
$imp = implode(',', $contactemaileach);
}
}