简体   繁体   中英

get user_id from variable using php

I have this variable $products that I'm getting from the db. Now when I print what's in it it shows

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 ( ) ) )

So my question is how can i get what is the product_id number?

I print this using print_r($products); but is gives me this error

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

This is the code that is causing this problem:

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

假设您将上面的print_r做的变量分配给$ products:

$products[0]['product_id']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM