Here is print_r output of my array:
Array ( [0] => stdClass Object ( [itemId] => 560639000019 [name] => Item no1 [code] =>
Another way to achieve the result is to use array_filter.
$array = array( (object)array('id' => 5), (object)array('id' => 4), (object)array('id' => 3) ); $array = array_filter($array, function($item) { return $item->id != 4; }); print_r($array);