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 trial

PHP Object-Oriented PHP Basics Building the Recipe Accessing Arrays

can't figure out what is wrong...

"Oops! It looks like Task 1 is no longer passing." I cant find the mistake, please help

index.php
<?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
andren
28,558 Points

You 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.

omg, i'm blind... thank you very much!

-- --
-- --
12,382 Points

Hi 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
andren
28,558 Points

Don't worry, It's pretty common for situations like this to occur, I've done the same quite a few times as well :smile:. 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.