I want to be able to join by commas values that have the same key.
I have this code:
Array
(
[0] => Array
(
[user123] => 50877214
)
[1] => Array
(
[user123] => 7776057
)
[2] => Array
(
[user456] => 53445145
)
[3] => Array
(
[user456] => 19487054
)
)
I would like to convert it to:
Array
(
[0] => Array
(
[user123] => "50877214,7776057",
)
[2] => Array
(
[user456] => "53445145,19487054",
)
)
My code:
$arr = array_map(null, ...$arr);
$temp = array_map(function ($item) {
return implode(",", $item);
}, $arr);
print_r($temp);die;
Result:
Array ( [0] => 50877214,7776057,53445145,19487054 )
apparently it is not possible to group by the key...