Multidemensional associative array

php Add comments

However we really see the value of this if we use an each construct

$dummy = asort($phonedirectory);
while(list($person) = each($phonedirectory))
{
  echo "".$person;
  // that next comma is important!
  while (list(,$persondetails) = each($phonedirectory[$person])) {
    echo " - ".$persondetails;
  }
}

Our out put here is:

  Fred Binns - 123 Cleveland - 111-222-5555
  Jane Roe - 123 Elm - 111-222-4444
  John Doe - 123 Main - 111-222-3333

Leave a Reply

You must be logged in to post a comment.

WebSite Powered by webHauser
Entries RSS Comments RSS Login