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!

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


Code Challenge Associative Arrays

OK Randy

U got me.

Whats missing?

           <h1>The Empire Strikes Back (1985)</h1>
          <?php $movie = array("movie");
   $movie[title] = "The Empire Strikes Back";
          $movie[year] = "1980";
          echo $movie["title"];
          echo $movie["year"];


Please and Thank you


3 Answers

Elliott Frazier
Elliott Frazier
Courses Plus Student 9,647 Points

When naming keys you need to wrap the name of the keys in quotation marks. except when using just numbers


$movie["title"] = "The Empire Strikes Back";
$movie["year"] = "1980";


Thanks M

Hent Hest van
Hent Hest van
6,087 Points

I had the exact same problem ;).

Randy Hoyt
Randy Hoyt
Treehouse Guest Teacher

At the end of step 3, the code is supposed to look like this:


$movie["title"] = "The Empire Strikes Back";

?><h1><?php echo $movie["title"]; ?> (1985)</h1>

<td>Robert Zemeckis</td>
<th>IMDB Rating</th>
<th>IMDB Ranking</th>

We are creating an array with information about The Empire Strikes Back in it, and we are replacing the static text that displays the information from Back to the Future with information from this array.

Does that help?