ameliabob Posted November 13, 2012 Share Posted November 13, 2012 Do the list and each functions work with multidimensional arrays? $families = array ( "Griffin"=>array ( "Peter", "Lois", "Megan" ), "Quagmire"=>array ( "Glenn", "Fred", "Melissa" ), "Brown"=>array ( "Cleveland", "Loretta", "Junior" ) ); Given this array what would " echo (each($families)); " will display each of the family names.Is there a function that allows me to see the second level? while (list($first,$second,$third) = each($families){ echo("First born is ".$first." next is ".$second);} Link to comment Share on other sites More sharing options...
justsomeguy Posted November 13, 2012 Share Posted November 13, 2012 each returns both the keys and values: http://www.php.net/manual/en/function.each.php The key is the family name, the value is the array. You can loop through that array or use list with it if you want to, it's a normal array. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now