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 trialevgenijs smelovs
1,819 Pointscan't figure out what is wrong...
"Oops! It looks like Task 1 is no longer passing." I cant find the mistake, please help
<?php
$colors = array('red','blue', 'green');
echo $colors[1];
$favorite_colors = array (
'mike' => 'green',
'jane' => 'blue',
'chris' => 'red'
)
echo $favorite_colors["mike"];
?>
2 Answers
andren
28,558 PointsYou forgot to close the $favorite_colors
array with a ;
(semicolon). If you add a semicolon on the end of the parenthesis then your code will pass.
-- --
12,382 PointsHi Evgenijs,
The code itself is fine, you only forgot to add a semicolon somewhere. :)
<?php
$colors = array('red', 'blue', 'green');
echo $colors[1];
$favorite_colors = array (
'mike' => 'green',
'jane' => 'blue',
'chris' => 'red'
); // this is where you forgot your semicolon
echo $favorite_colors["mike"];
?>
Happy coding! :)
Edit: Oops, had this page open for a bit - did not see Andren had already answered your question. :P
andren
28,558 PointsDon't worry, It's pretty common for situations like this to occur, I've done the same quite a few times as well . Since formulating an answer can take a bit of time it's not a rare occurrence for multiple people to post answers somewhat around the same time.
evgenijs smelovs
1,819 Pointsevgenijs smelovs
1,819 Pointsomg, i'm blind... thank you very much!