我从db获取此变量$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);
答案 0 :(得分:1)
假设您所做的变量上面的print_r被分配给$ products:
$products[0]['product_id']