0

我有这个从数据库中获取的变量$products。现在,当我打印其中的内容时,它会显示

Array ( [0] => Array ( [quantity] => 1 [product_id] => 5363 [category_id] => 209 [price] => 1 [tax] => 18.00 [tax_id] => 1 [description] => [product_name] => test2 [thumb_image] => [ean] => [attributes] => a:0:{} [attributes_value] => Array ( ) [weight] => 0.0000 [vendor_id] => 0 [files] => a:0:{} [freeattributes] => a:0:{} [dependent_attr_serrialize] => a:0:{} [href] => /kategorii/product/view/209/5363.html [free_attributes_value] => Array ( ) ) )

所以我的问题是我怎样才能得到 product_id 号码?

我打印这个使用print_r($products);但是给了我这个错误

Warning: current() [function.current]: Passed variable is not an array or object in ...

这是导致此问题的代码:

$cart = JModel::getInstance('cart', 'jshop');
        $cart->load();  
        $products=$cart->products;
        //$productos[0]['product_id'];
        print_r($products);
4

1 回答 1

1

假设您执行上述 print_r 的变量已分配给 $products:

$products[0]['product_id']
于 2012-12-08T11:18:38.200 回答