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 trialKyle Plancich
7,482 PointsI really don't get what I'm doing wrong
It says "I don't see a key named 'mike' " In my mind it's clearly there. I don't understand whats wrong.
<?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];
$favorite_colors = array('mike','jane','chris');
$mike = 'green';
$jane = 'blue';
$chris = 'yellow';
?>
2 Answers
Anupam Majhi
5,826 PointsIt is asking you to add "Associative Array" and what you are writing is an "Indexed Array"
You should do this:
<?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];
$favorite_colors = array('mike'=>'green','jane'=>'blue','chris'=>'yellow');
?>
To understand more visit : http://www.w3schools.com/php/php_arrays.asp
Pepe Suarez
18,267 PointsHey Kyle!! You have to do an associative array at the end. What you did wrong is that you are creating new variables and adding the colors string to each one. You are supposed to make the $favorite_colors array in a 'key' and 'value' assignment. Here is how I completed the challenge so you can check more in detail how you are supposed to make an associative array.
<?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];
// associative array: $example = array('key' => 'value')
$favorite_colors = array('mike' =>'green',
'jane'=>'blue',
'chris'=>'yellow');
?>