I have this type array
Array
(
[0] => Array
(
[id] => 90
[name] => Paul
[company] => Google
[date] => 2018-01-06
[total] => 100.00
)
[1] => Array
(
[id] => 90
[name] => Paul
[company] => Google
[date] => 2018-07-06
[total] => 100.00
)
[2] => Array
(
[id] => 89
[name] => Ethan
[company] => Yahoo
[date] => 2018-07-10
[total] => 1140.00
)
)
I need to create a new array from the previous one by merging id and name if they are the same.
The desired output should be:
[[
[id] => 90
[name] => Paul
[company] => Google,
[data] => [
[date] => 2018-01-06,
[total] => 100.00
],
[
[date] => 2018-07-06,
[total] => 100.00
],
], [
[id] => 89
[name] => Ethan
[company] => Yahoo
[data] => [
[date] => 2018-07-10,
[total] => 1140.00
]
]]
What I have tried before:
$output = array();
foreach($input as $data){
$output[$data['id']][] = $data;
$output[$data['name']][] = $data;
$output[$data['company']][] = $data;
}
What I'm missing here please ?
Thanks.
idbut I do not want to duplicate each time the same infosnameandcompany.