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!
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 trial
Accessing arrays: failing task despite echoing correct variable.
echo $favorite_colors['mike']; returns green, which is asked for by the task.
I have tried changing around the order of the $colors array variables, and the associative array indexes, but nothing will allow me to pass this task.
Anybody else have any luck?
I know I have gotten it correct, it's just bugging me that I can't pass the task.
<?php //Place your code below this comment $colors = array( 'red', 'blue', 'green' ); $favorite_colors = array( 'mike' => $colors, 'jane' => $colors, 'chris' => $colors ); echo $favorite_colors['mike']; // green ?>
I just did the challenge again to get my head around it:
the following code passed:
/Place your code below this comment $colors = ['red','blue','green']; echo $colors; $favorite_colors = [ 'mike' => $colors, 'jane' => $colors, 'chris' => $colors ]; echo $favortie_colors['mike'];
But out of curiosity what error message comes up? Your output is all correct, too.