删除嵌套PHP数组中的条目[关闭]

I want to delete the entry identified by c9f0f895fb98ab9159f51fd0297e236d from the array below. How could I do this? Your help will be greatly appreciated. Thanks in advance.

 array (size=12)
   'session_id' => string 'd1ac9074e254a49429c6ad3aeb19aef5' (length=32)
   'ip_address' => string '127.0.0.1' (length=9)
   ...
   'cart_contents' => 
     array (size=8)
       'c9f0f895fb98ab9159f51fd0297e236d' => 
         array (size=15)
           'id' => string '8' (length=1)
           'code' => string 'aloo-chana-puri-v' (length=17)
           ...
       ...
unset($foobar['cart_contents']['c9f0f895fb98ab9159f51fd0297e236d']);

edit:

According to your attempted edit to my post, you are usign something like

$top = $this->session->all_userdata(); 
unset($top['cart_contents'][$mykey]); 
var_dump($this->session->all_userdata());

The reason for the failure is that you do unset the value in withhin $top but not withhin $this->session. You must understand that the assignment operator in the first line does copy the value, not reference it.