Full Version: how to display first key in a 2 dimentional array
UtterAccess Forums > And More... > PHP, Perl, MySQL and Postgres
I have an array set up and what I am doing is learning how to use php functions, global vars, and looping; so this is an excersize for me. It works just fine but I can not figure out how to display the two position state abbreviation in the output. When I use the variable $state then the value displayed is 'array'. Help, thx all!
$statecapitals['AR']['Arkansas']='Little Rock';
     function format_display()
     global $capitalState, $city;
     echo "The capital of $capitalState is $city.<br>";
     foreach ($statecapitals as $state)
     foreach ($state as $capitalState => $city)
I know how to retrieve all the columns using list() and extract(), so getting the value of all the columns is not a problem for me. I just wondered why I can't get that first key with my foreach loop. Hmmm, and no comments?!?
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.