Jump to content

Multidimensional Array Problem!


kts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.