Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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.