I have a array that looks a bit like this
array(
[0] => array(
['id'] => 29
['name'] => john
)
[1] => array(
['id'] => 30
['name'] => joe
)
[2] => array(
['id'] => 29
['name'] => jake
)
)
And that goes on for a while.
I've found the question elsewhere (here) and (here) But neither works.
With the first one I get the following array
array(
[0] => 29
[1] => jake
)
And with te second one it only filters out exact duplicates and not duplicates with jus the same id
.
I want all the duplicates with the same id
removed from the array, how do I do that?
Simple with PHP >= 5.5.0:
$result = array_column($array, null, 'id');
Optionally:
$result = array_values(array_column($array, null, 'id'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With