3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array ('1' => (object)array( 'id' => 225, 'user_id' => 1, 'name' => 'Blue Quilted Leather Jacket by Minusey - $499' ), '2' => (object)array( 'id' => 222, 'user_id' => 1, 'name' => 'Darling New Bathtub by Duravit - $6300' ), '3' => (object)array( 'id' => 222, 'user_id' => 1, 'name' => 'Darling New Bathtub by Duravit - $6300' ) ); //print_r(array_column((array)$array, 'id')); $UniqueArray = array(); foreach($array as $key=>$value){ // rebuild your array //$id = $value['id']; //build array with unique key value $id = $value->id; //object $UniqueArray[$id] = $value; } print_r($UniqueArray);
based on 5FSDN
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [225] => stdClass Object ( [id] => 225 [user_id] => 1 [name] => Blue Quilted Leather Jacket by Minusey - $499 ) [222] => stdClass Object ( [id] => 222 [user_id] => 1 [name] => Darling New Bathtub by Duravit - $6300 ) )