从数组中取消设置项目0

I have a simple section of code which removes an item from an array buy the key value which is submitted into the url.

here it is.

if ($this->uri->segment(5))
    {
    unset($body_data['ccs'][$this->uri->segment(5)]);
    $newcc = $body_data['ccs'];

    $postcc = implode(",", $newcc);

    if($this->ticket_model->save_cc($postcc, $ticket_id))
            {
            redirect(base_url().'ticket/edit/'.$ticket_id.'/11/');
            return;
            }
    }

This is working how i want it too, however it will not unset an item which is at the start of the array, key value zero. is there a trick I am missing?

if ($this->uri->segment(5))

when this is === 0 it is == false and the code in your if won't run. change it to

if (isset($this->uri->segment(5)))