php de supprimer l'objet de tableau d'objets

Je suis en train de supprimer un objet d'un tableau d'objets par son indice. Voici ce que j'ai obtenu jusqu'à présent, mais je suis perplexe.

$index = 2;

$objectarray = array(
0=>array('label'=>'foo', 'value'=>'n23'),
1=>array('label'=>'bar', 'value'=>'2n13'),
2=>array('label'=>'foobar', 'value'=>'n2314'),
3=>array('label'=>'barfoo', 'value'=>'03n23')
);

//I've tried the following but it removes the entire array.
foreach ($objectarray as $key => $object) {
 if ($key == $index) {
   array_splice($object, $key, 1);
   //unset($object[$key]); also removes entire array.
 }
}

Toute aide serait appréciée.

Mise À Jour De La Solution

 array_splice($objectarray, $index, 1); //array_splice accepts 3 parameters 
    //(array, start, length) removes the given array and then normalizes the index
    //OR 
    unset($objectarray[$index]); //removes the array at given index
    $reindex = array_values($objectarray); //normalize index
    $objectarray = $reindex; //update variable 
Ce que vous essayez de supprimer exactement?
2=>array('label'=>'foobar', 'value'=>'n2314'

OriginalL'auteur toddsby | 2014-02-04