Jump to content

Recommended Posts

Hey everyone, I have this array that I'm trying to grab the "value" piece from, but I'm extremely confused... when I print_r($order->products);

 

 

 

Array ( [0] => Array ( [qty] => 1 [name] => book test 39 [model] => [tax] => 0.0000 [price] => 1.0000 [final_price] => 1.0000 [products_warehouse_location] => [attributes] => Array ( [0] => Array ( [option] => Size [value] => Youth Large [prefix] => + [price] => 0.0000 ) ) ) ) 

 

 

echoing $order->products[$i]['name']; shows the name, but echoing $order->products[$i]['value'] shows nothing... Am I missing something, is it a different array?

Link to comment
https://forums.phpfreaks.com/topic/169123-multidimensional-array-problem/
Share on other sites

use this when echoing arrays/objects:

echo nl2br(str_replace(' ',' ',print_r($order->products)));

 

 

 

$order->products[0]['attributes'][0]['value']

 

 

you've got an array of products

but each product has information attached to it ALSO in an array

 

so you have an array of an array of product data

 

each product data can have different attributes such as size  etc etc etc

and each group of attributes are in an array

 

so in the end you have array of an array of product data where the different attributes of the product are an array

 

:P

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.