Nic Hubbard
Nic Hubbard

Reputation: 42139

Multidimensional array only returning one item in PHP

I have a multidimensional array, that is a few levels deep. I am trying to loop through some of the lower levels of array items, but when I do, it seems to only return one of the array items.

foreach ($items as $item) {
  foreach ($item as $id) {
    echo $id;
  }
}

For some reason, echoing $id only returns the first item in the $item array, how would I look through all items in the $item array, and echo those as well?

Upvotes: 1

Views: 405

Answers (2)

Steven
Steven

Reputation: 3843

var_dump() is always my favorite.

Upvotes: 2

nairdaen
nairdaen

Reputation: 1047

First, are you totally sure it is a multidimensional array? I'd try to check my $items structure using

print_r($items)

Upvotes: 2

Related Questions