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 trialJoy Ahmed
Courses Plus Student 9,687 PointsCode 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
Philip G
14,600 PointsThe 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.
Philip G
14,600 PointsDid this answer help? :)
Joy Ahmed
Courses Plus Student 9,687 Pointsyes... it was a technical error... thank u
Patrick Meehan
4,640 PointsStill 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
4,640 Pointscan someone check on this problem?
Philip G
14,600 PointsThis 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
Ryan McKeown
6,999 PointsWhy is this still not fixed? Below is my code and it is not accepting. $colors = array('red', 'blue', 'green'); echo $colors[1];
Philip G
14,600 PointsMaybe you wrote the wrong colors or in the wrong order, try this:
$colors = array( 'green', 'blue', 'brown'); echo $colors[1];
Carmen Joubert
6,637 PointsSame problem here.
echo $colors[1];
Ashton Mattocks
3,129 PointsHeres 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']; ?>
Ryan McKeown
6,999 PointsWhat 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.
hamza fahad
Courses Plus Student 1,188 Pointshello, 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];
Krishnanath Maly
Android Development Techdegree Student 6,095 PointsKrishnanath Maly
Android Development Techdegree Student 6,095 Points