php - Filter 2 dimensional array -


i have array looks bit this

array(     [0] => array(         ['id'] => 29         ['name'] => john         )     [1] => array(         ['id'] => 30         ['name'] => joe         )      [2] => array(         ['id'] => 29         ['name'] => jake         )  ) 

and goes on while.

i've found question elsewhere (here) , (here) neither works.

with first 1 following array

array(     [0] => 29     [1] => jake ) 

and te second 1 filters out exact duplicates , not duplicates jus same id.

i want duplicates same id removed array, how do that?

$filteredusers = []; foreach ($users $user) {     $filteredusers[$user['id']] = $user; }  // optionally: // $filteredusers = array_values($filteredusers); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -