Skip to content

Instantly share code, notes, and snippets.

@mchelen
Last active January 17, 2017 16:36
Show Gist options
  • Save mchelen/255c15d18ab594b210efb36475a50f5a to your computer and use it in GitHub Desktop.
Save mchelen/255c15d18ab594b210efb36475a50f5a to your computer and use it in GitHub Desktop.
multidimensional array dedupe
<?php
$array = [
0 => [
'id' => 'a'
],
1 => [
'id' => 'b'
],
2 => [
'id' => 'a'
],
];
foreach ($array as $element) {
$result[$element['id']] = $element;
}
$result = array_values($result);
var_export($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment