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

using the $colors array how do i echo the second value

using the $colors array how do i echo the second value.

this 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

3 Answers

Heyy!

You can use:

echo $colors[1];

Hope it helps!

For an array like that it goes:

$colors = array['

[0] => ['red'],
[1] => ['blue'],
[2] => ['green']
']

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