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 trialAdeline Itayi Chikurunhe
901 Pointsusing the $colors array how do i echo the second value
using the $colors array how do i echo the second value.
3 Answers
henriquegiuliani
12,296 PointsHeyy!
You can use:
echo $colors[1];
Hope it helps!
Shaun Moore
6,301 PointsFor an array like that it goes:
$colors = array['
[0] => ['red'],
[1] => ['blue'],
[2] => ['green']
']
Daniel Baker
3,198 PointsI keep trying echo $colors[1]; and it keeps telling me that it is the wrong answer. I have tried every variation that I can think of and it still will not tell me that it is correct.
Adeline Itayi Chikurunhe
901 PointsAdeline Itayi Chikurunhe
901 Pointsthis is how i am doing it. <pre><?php $colors=array('red','blue','green') in echoing the second value i did this; echo $colors[0] and this is not working