0

How can I loop this type of array where only attribute name has another array? Thanks


     array(
        '0' => array(
            'id' => 1,
            'name' => array(
                'firstname' => 'pat',
                'last' => 'lozan'
            )
        ),
        '1' => array(
            'id' => 2,
            'name' => array(
                'firstname' => 'bob',
                'last' => 'brown'
            )
        ) 
    )
1
  • Do you want a way to read this specific kind of an array or any array where some elements are arrays and some are not? Commented May 11, 2013 at 13:43

1 Answer 1

1

You can still just use foreach, nothing changes there..

foreach ($array as $item) {
  echo $item['name']['firstname'];
}
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.