Php 在codeigniter购物车会话中获取指定数组

Php 在codeigniter购物车会话中获取指定数组,php,arrays,codeigniter,session,cart,Php,Arrays,Codeigniter,Session,Cart,有没有办法在codeigniter的cart会话中获取指定的数组 例如,我有这些值 Array ( [c81e728d9d4c2f636f067f89cc14862c] => Array ( [rowid] => c81e728d9d4c2f636f067f89cc14862c [id] => 2 [qty] => 1 [price] => 100

有没有办法在codeigniter的cart会话中获取指定的数组

例如,我有这些值

Array
(
    [c81e728d9d4c2f636f067f89cc14862c] => Array
        (
            [rowid] => c81e728d9d4c2f636f067f89cc14862c
            [id] => 2
            [qty] => 1
            [price] => 1000
            [name] => Pin 
            [subtotal] => 1000
        )

    [c4ca4238a0b923820dcc509a6f75849b] => Array
        (
            [rowid] => c4ca4238a0b923820dcc509a6f75849b
            [id] => 1
            [qty] => 3
            [price] => 100
            [name] => Amber
            [subtotal] => 300
        )

)
我只想得到数组“c4ca4238a0b923820dcc509a6f75849b”的值

我试过了

$this->session->userdata("c81e728d9d4c2f636f067f89cc14862c");


但是它不起作用

您可以使用
$this->cart->contents()获取购物车项目来获取特定的密钥,只需这样调用即可

$getCartItem = 'c4ca4238a0b923820dcc509a6f75849b';
$cartItems = $this->cart->contents();

if( isset($cartItems[$getCartItem]) ) 
{
    $item = $cartItems[$getCartItem];
    // do stuff

} else {
    //not found
}

你可以这样写你自己的函数

 public function getCartInfo($rowId)
    {

        $cart = $this->cart->contents();
        if( isset($cart[$rowId])) //your $rowId="c81e728d9d4c2f636f067f89cc14862c"
        {
            $data = $cart[$rowId];
            echo "<pre>";
            print_r($data); //view specific cart information
        } 
        else 
        {
            echo "not found";
        }
        exit();
    }
公共函数getCartInfo($rowId)
{
$cart=$this->cart->contents();
if(isset($cart[$rowId])///your$rowId=“c81e728d9d4c2f636f067f89cc14862c”
{
$data=$cart[$rowId];
回声“;
打印($data);//查看特定购物车信息
} 
其他的
{
回声“未找到”;
}
退出();
}
 public function getCartInfo($rowId)
    {

        $cart = $this->cart->contents();
        if( isset($cart[$rowId])) //your $rowId="c81e728d9d4c2f636f067f89cc14862c"
        {
            $data = $cart[$rowId];
            echo "<pre>";
            print_r($data); //view specific cart information
        } 
        else 
        {
            echo "not found";
        }
        exit();
    }