Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Henrique Voni
Henrique Voni
12,296 Points

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.