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

PHP object-oriented, $colors task 2 of 5

The challenge is "Add three colors to your array: 'red', 'blue', & 'green'. "

Keep getting: Bummer: the color red does not seem to be a value in your array

Not sure what I'm doing wrong. I copied the same format used in the associative array video. I thought values came after fat arrows so not sure what is going on.

Any help would be appreciated! Going crazy trying to figure this out

index.php
<?php

//Place your code below this comment

$colors[] = array(
  "red" => $red, 
  "blue" => $blue, 
  "green" => $green
  );
?>

3 Answers

Mark Sebeck
MOD
Mark Sebeck
Treehouse Moderator 37,353 Points

Sorry Emilie. after closer look that will not work. You need to just make a simple array not an associative array like they did in the video. You just want to store colors. So something like this:

$colors = array("red", "blue", "green");
Mark Sebeck
MOD
Mark Sebeck
Treehouse Moderator 37,353 Points

Hi Emilie. The good news is your code is correct. The bad news is the challenge checker seems to have an issue with new lines. Try putting your array all on one line and it should pass.

$colors = array("red" => $red, "blue" => $blue, "green" => $green);

Keep at it Emilie and be sure to post back to the community if you get stuck.

Hi Mark, thanks so much for the reply. The second one worked!