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 Build a Simple PHP Application Listing Inventory Items Associative Arrays

Uros Mitic
Uros Mitic
5,472 Points

Need help with: "Add an element to the movie array with a key of "year" and a value of 1980."

Guys i need some help.I do not see how my code is wrong (maybe i'am missing something out) .But i get "Bummer! It looks like you don't have a "year" element in the $movie array." error. Here is my code:

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

1 Answer

Gareth Borcherds
Gareth Borcherds
9,372 Points

Sometimes the code verification engine is a little finicky. Try adding it all on separate lines.

<?php
$movie = array();
$movie["title"] = "The Empire Strikes Back";
$movie["year"] = 1980; 
?>
Uros Mitic
Uros Mitic
5,472 Points

Thanks for your reply.I have tried to do that but still no luck.I got the same error.

Gareth Borcherds
Gareth Borcherds
9,372 Points

Here is my complete code, maybe check against this to see if you are doing something different. I think it's just something the code verification engine is messing up as your code looks correct.

<?php
$movie = array();
$movie["title"] = "The Empire Strikes Back";
$movie["year"] = 1980; 
$movie["director"] = "Irvin Kershner";
$movie["imdb_rating"] = 8.8;
$movie["imdb_ranking"] = 11;
?>

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

<table>
<tr>
<th>Director</th>
<td><?php echo $movie["director"];?></td>
</tr>
<tr>
<th>IMDB Rating</th>
<td><?php echo $movie["imdb_rating"];?></td>
</tr>
<tr>
<th>IMDB Ranking</th>
<td><?php echo $movie["imdb_ranking"];?></td>
</tr>
</table>
Uros Mitic
Uros Mitic
5,472 Points

I copied your part of the code and it worked.Still can't spot the difference.I think you are right about code verification engine.Thanks a lot for your time and effort, you saved me! Wish you all the best. :)