Here is print_r output of my array:
Array
(
[0] => stdClass Object
    (
        [itemId] => 560639000019
        [name] => Item no1
        [code] =>         
        try this
foreach($array AS $key=>$object){
   if($object['id'] == 4){
       $key_in_array = $key;
   }
}
// chop it from the original array
array_slice($array, $key_in_array, 1);
                                                                        foreach( $arr as $k=>&$a) {
    if( $a['id'] == 4 )
        unset($arr[$k]);
}
                                                                        In my case, this my array as $array
I was confused about this problem of my project, but some answer here helped me.
array(3) { 
           [0]=> float(-0.12459619130796) 
           [1]=> float(-0.64018439966448) 
           [2]=> float(0)
         }
Then use if condition to stop looping
foreach($array as $key => $val){
           if($key == 0){ //the key is 0
               echo $key; //find the key
               echo $val; //get the value
           }
        }
                                                                        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);