0

I want to extract item 6 and item 9 from an array, I can get ingle values out using the [0] singled indexed row

But looking for the vector this does not work

$vector1 =  ($result['item3']['item6'][‘item9’]);

What is the best way to extract the arrays for item 6 and item 9 ?

Array
([0] => Array
    ([item1] => 123
     [item2] => 345
     [item3] => Array
        ([0] => Array
            ([item4] => Array
                ([item6] => 567
                 [item7] => 678
                 [item8] => Array
                    ([0] => Array
                        ([item9] => abc)
                    )
                )
            )
        )
    )
)
3
  • 2
    If it's a static array, then $result[0]['item3'][0]['item4']['item6'] and $result[0]['item3'][0]['item4']['item8'][0]['item9'] Commented May 15, 2014 at 23:31
  • 1
    ^ just barely beat me. Commented May 15, 2014 at 23:31
  • 2
    This is a rather inconsistent datastructure. I think you need to rethink it. Commented May 15, 2014 at 23:34

1 Answer 1

3
$item6 =  $result[0]['item3'][0]['item4']['item6'];

$item9 =  $result[0]['item3'][0]['item4']['item8'][0]['item9'];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.