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 trialCorey Lyons
24,684 PointsAccessing Arrays Task 4
It says to add a new associative array with values for each. Here is what I have:
<?php
$colors = array('red', 'blue', 'green');
echo $colors[1];
$favorite_colors = array(
'mike' -> 'green',
'jane' -> 'blue',
'chris' -> 'red'
);
?>
1 Answer
Jennifer Nordell
Treehouse TeacherHi there, Corey! You're really close here. We use the ->
when we're accessing a property. But we use the =>
kind of "arrow" when we're making associative arrays.
So without changing anything else, if I simply change the ->
to =>
, your code passes with flying colors! This needs to be done on all three key/value pairs.
Hope this helps!
Corey Lyons
24,684 PointsCorey Lyons
24,684 PointsThanks, it's easy to get the arrows mixed up when they look similar!