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

PHP

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

M

3 Answers

Elliott Frazier
PLUS
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

Example:

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

D'oh.

Thanks M

Hent Hest van
Hent Hest van
6,087 Points

I had the exact same problem ;).

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

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

<?php

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

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

<table>
<tr>
<th>Director</th>
<td>Robert Zemeckis</td>
</tr>
<tr>
<th>IMDB Rating</th>
<td>8.5</td>
</tr>
<tr>
<th>IMDB Ranking</th>
<td>53</td>
</tr>
</table>

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?