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 Object-Oriented PHP Basics Building the Recipe Accessing Arrays

Corey Lyons
Corey Lyons
24,684 Points

Accessing Arrays Task 4

It says to add a new associative array with values for each. Here is what I have:

index.php
<?php

$colors = array('red', 'blue', 'green');

echo $colors[1];

$favorite_colors = array(
  'mike' -> 'green',
  'jane' -> 'blue',
  'chris' -> 'red'
  );

?>

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi 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! :sparkles:

Corey Lyons
Corey Lyons
24,684 Points

Thanks, it's easy to get the arrows mixed up when they look similar!