Associative 2-dimensional arrays

php Add comments

Associative two dimensional arrays can be useful as in this phone book example.

//multidemensional associative array
$phonedirectory=array(
"John Doe" => array("123 Main","111-222-3333"),
"Jane Roe" => array("123 Elm","111-222-4444"),
"Fred Binns" => array("123 Cleveland","111-222-5555")
);
echo $phonedirectory["John Doe"][0]." - ".$phonedirectory["John Doe"][1];

Our output here is: 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