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 trialTingting Gu
10,760 PointsCould you tell me why I cannot pass task 5 of 7 on Stege 4(Listing inventory items) ?
I wrote codes as the follows but failed. Could you tell me why?
<?php
$movie = array(
"title"=> "The Empire Strikes Back",
"year" => 1985,
"director" => "Robert Zemeckis",
"rating" => 8.5,
"ranking" => 53
);
?>
<h1><?php echo $movie["title"]. " (". $movie["year"]. ")"; ?></h1>
3 Answers
Lucas Santos
19,315 PointsYour array looks fine to me only thing I can think of maybe is that you have all double quotation in the echo statement below and I don't know why you are concatenating a white space after the movie year? try this instead
<?php echo $movie["title"] ." ('. $movie["year"]')"; ?>
George Cristian Manea
30,787 PointsYour code is correct, maybe is something else the problem. Is this the whole code for the challange or just a part of it?
Rashaad Prince
7,129 PointsI agree with George. My code is identical and it worked just fine. The only difference is I created two separate PHP statements on the same line inside the <h1> tag (one for the title key and one for the year key). This had me stuck for 3 days and I just solved it an hour ago.
<h1><?php echo $movie["title"];?><?php echo "(".$movie["year"].")"?></h1>
"This too shall pass" -_-