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

can't figure this one out

Hi, I am trying to figure out task 5. I get a message that previous task does not pass. Any help here? Task: list two keys and two values within an HTML code. I tried without concatenation as two separate php strings and it didn't work either. Nothing turned up on Google.

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

<table> <tr> <th>Director</th>

2 Answers

Nathan Newell
Nathan Newell
7,634 Points
<?php
 $movie = array(
 "title" => "The Empire Strikes Back",
 "year" => "1980" 
);
 ?>

 <?php echo $movie ["title"] .  ' (' . $movie["year"] . ')' ; ?>

I found the problem was that you needed to alternate the single and double quotes in the echo statement. Have a look at the code here and it might refresh your memory to previous lessons.

Still working on this. I tried the code you sent and it didn't work. I also tried without the concatenation and it didn't work. I have another question in to the forum. Let me know if you have further thoughts. Thx.

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

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