1

I am trying to retrieve values from a multidimensional array. In this case below code is working

echo $orderList['Orders']['Order'][1]['OrderItems']['OrderItem']['SKU']; 

But this is not working

for($i=0;$i<count($orderList);$i++) { $order_info['order_sku'] = $orderList['Orders']['Order'][$i]['OrderItems']['OrderItem']['SKU']; } 

Can anyone say what is the problem ??

UPDATE

Actually my array like below.I would like to retrieve RowId value; Thanks

Array ( [0] => Array ( [OrderItems] => Array ( [OrderItem] => Array ( [RowId] => 1 ) ) ) ) 
1
  • 3
    for($i=0;$i<count($orderList['Orders']['Order']);$i++) Commented Mar 11, 2015 at 12:19

2 Answers 2

1

Perhaps

for($i=0;$i<count($orderList['Orders']['Order']);$i++) { ... } 

or even

foreach($orderList['Orders']['Order'] as $order) { $order_info['order_sku'] = $order['OrderItems']['OrderItem']['SKU']; } 
Sign up to request clarification or add additional context in comments.

Comments

0

How about:

for($i=0;$i<count($orderList);$i++) { $order_info['order_sku'] = $orderList[$i]['OrderItems']['OrderItem']['RowId']; } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.