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

Now using the $colors array, echo the second value.

Now using the $colors array, echo the second value.

index.php
<?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']; /


?>

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

Hi there,

You're almost there but what you're doing is echoing a string.

To echo the second value of the array you need to use a whole number like this

echo $colors[1]; 

Also you used a capital C to reference your $colors array but this doesn't match your original declaration. :-)

Jeff Lemay
Jeff Lemay
14,268 Points

It looks like you're really close. You just need to update your formatting:

  • variables/arrays are case-sensitive
  • remove quotes from around the index/number (numbers typically don't need to be wrapped in quotes, unlike strings of text)
  • put your index [1] right next to the array name
  • remove the random slash after your echo statement
<?php
echo $colors[1]; 
?>