Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMark Miller
45,831 PointsWhy are there two months for one key?
I've reviewed all the videos, but this question is not explained.
3 Answers
Carlos Alberto Del Cueto Carrejo
13,817 PointsIt is a quesiton in the quiz , for everyone else here is the code example:
$myArray = array("January" => "Winter", "February" => "Winter",
"March" => "Spring", "April", "May" => "Spring", "June" => "Summer",
"July" => "Summer", "August" => "Summer", "September" => "Fall",
"October" => "Fall", "November" => "Fall", "December" => "Winter");
What is the key of the fourth element of the array ?
I'll explain from here, I can understand your confusion but Treehouse threw a really clever question, if you think that the array contains only pairs of Keys => Values, then it would look like the array has two keys on the fourth element. But remember that an array can contain different types of data, even objects. In this case the fourth element in the array is just the string "April" , hence the value of it's key is zero. Hope this is clear enough. Good luck , keep coding.
Juan Ignacio Lambardi
3,943 PointsHi Mark, wich exercise is?
Alexander Rodriguez, MD
6,642 PointsThis question is found in the "Associative Quiz" in "PHP Arrays and Control Structures" in the PHP Track.
BTW, thanks to Carlos for answering this question. This one tricked me as well.
Alex
Rich Zimmerman
24,063 PointsRich Zimmerman
24,063 PointsCan you give an example of the code?