tags:

views:

47

answers:

3

findParent() function returns the following array.

Array
(
    [0] => Array
        (
            [order_item_id] => 3
            [order_id] => 2
            [product_id] => 77
            [quantity] => 1
            [price] => 268.00
        )

)

I want to get 2 in [order_id].

I tried the following but it does not work.

$childlessorder = findParent($order_id);
$order_id = $childlessorder['order_id'];

Can anyone tell me how to get data in an array?

A: 
$order_id = $childlessorder[0]['order_id'];
Allain Lalonde
A: 
$childlessorder = findParent($order_id);
$order_id = $childlessorder[0]['order_id'];

?

code_burgar
+4  A: 

Try using:

$childlessorder = findParent($order_id);
$order_id = $childlessorder[0]['order_id'];

The function findParent() is returning a two dimensional array as is apparent from the two Array words in the dump. So to access any value from this array we need to use two indices. Think of this as a matrix with the element you're interested lying in xth row yth column. With x being 0 and y begin 'order_id'.

codaddict