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 trialCortney Burgess
10,758 PointsAdd an element to the movie array with a key of "year" and a value of 1980.
$movie = array ("year" => "1980" ); ?>
what am i doing wrong
3 Answers
Mark Southard
9,502 PointsCouple things I see. There is a space between array and ( that shouldn't be there. Second, I believe the year should be an integer and not a string.
Jennifer Rai
Courses Plus Student 13,164 PointsYup, Mark is right. Also, they are asking you to add a new key/value pair to the existing array, so you don't have the syntax right to do that. You can either add the new key/value pair to the first line of code by separating it with a comma like this:
$movie = array("title"=>"The Empire Strikes Back", "year"=>1980);
Or you can do it on a separate line.
$movie = array();
$movie["title"] = "The Empire Strikes Back";
$movie["year"] = 1980;
I am not sure which way they were showing you how to do it in the lesson. Either way, understanding arrays is one of the most important things when learning PHP (in my opinion anyway) so I would suggest watching the video again to make sure you have a firm grasp on it.
Good luck!
Francisco Santiago
9,591 PointsThis the actual answer for anyone else that gets stuck!!!
<?php $movie = array("title"=>"The Empire Strikes Back", "year"=>1980); ?>
<h1><?php echo $movie["title"]?> (1985)</h1>