My function store elements in an array like this:
array (
0 =>
array (
'name' => 'Roger',
'id' => '1',
),
1 =>
array (
'name' => 'David',
'id' => '2',
),
2 =>
array (
'name' => 'David',
'id' => '2',
),
)
I used array_unique($myArray), but it returns only the non-duplicate elements.
array (
0 =>
array (
'name' => 'Roger',
'id' => '1',
),
)
I need 1 out of each duplicate elements.
This is not too difficult and can be solved with basic PHP. Assume that your data is stored in the variable
$rowsthen you can do this:The result will be in
$output. For a live demo see: https://3v4l.org/B8FUKIn case you want normalize keys you can do: