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 PHP Basics (Retired) PHP Datatypes PHP Datatypes Challenge

Code Challange Question - Now using the $colors array, echo the second value.

answered as below:

$colors = array( 'green', 'blue', 'brown'); echo $colors[1];

But my answer is not accepted... am I wrong?

6 Answers

The code should work... Maybe it's a technical error, too :)

P.S.: I recommend you to use the Markup Code Block. Click the Markdown Cheatsheet Link under the textarea.

Did this answer help? :)

yes... it was a technical error... thank u

Patrick Meehan
Patrick Meehan
4,640 Points

Still messed up. The colors they ask for are ('red', 'blue', & 'green') Here is my code

<?php

//Place your code below this comment
$integer_one = 1;
$integer_two = 2;
$golden = 1.618;

$bool = true;

$colors = array('red', 'blue', 'green');

echo $colors[1]

?>
Patrick Meehan
Patrick Meehan
4,640 Points

can someone check on this problem?

This code works for me, but you didn't include the code for the last task:

$favorite_colors = array("mike" => "green", "jane" => "blue", "chris" => "yellow");

Also make sure that you add the semicolon for the echo statement.

Best Regards, Philip

Why is this still not fixed? Below is my code and it is not accepting. $colors = array('red', 'blue', 'green'); echo $colors[1];

Maybe you wrote the wrong colors or in the wrong order, try this:

$colors = array( 'green', 'blue', 'brown'); echo $colors[1];

Same problem here.

echo $colors[1];

Heres the correct code:

<?php

//Place your code below this comment $integer_one = 1;

$integer_two = 2;

$golden = 1.618;

$bool = true;

$colors = array('red', 'blue', 'green');

echo $colors['1']; ?>

What I did was I started over from scratch on the challenge and it ran successfully. I believe that once you put in the wrong code, it has trouble recognizing the new code and so it continues to give you the wrong answer message.

hello, Follow my instruction. Write the array and write colors name instead of these and all will be okay.

$colors = array( 'green',
'yellow',
'blue' );

echo $colors[1];