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

Carlos Hempel
Carlos Hempel
8,303 Points

Problem with this code challenge

Hello All,

I am having a little issue with the code challenge at Stage 4 "Listing Inventory Items" from PHP development.

I only need to display the title of the new movie from the array shown below between the <h1> tags. I think the code its fine but the site tells me there is something not correct and ask me to double-check the parentheses and the year.

Is there something I am missing? maybe I donยดt understand what needs to be done?

```<?php $movie = array(); $movie["title"] = "The Empire Strikes Back"; ?> <h1>Back to the Future (1985)<?php echo $movie["title"]; ?></h1>


2 Answers

Benjamin Lim
Benjamin Lim
17,880 Points


Went through the code challenge and the question is to REPLACE the movie title. The code you written which uses arrays are associative arrays which uses the '=>' operator, to link to the array keys. You would need to:

  1. Create an associative array.
  2. Replace the title of static movie text ("Back to the Future") by calling the array.

The below code should get you through hope this helps! ;)

  $movie = array(
    "title"=>"The Empire Strikes Back"

<h1><?php echo $movie["title"]; ?> (1985)</h1>
Carlos Hempel
Carlos Hempel
8,303 Points


That worked! thanks

Benjamin Lim
Benjamin Lim
17,880 Points

Could you post the question? From your script it would seem the following would be displayed :

Back to the Future (1985)The Empire Strikes Back

Looks kinda wrong. Hope this helps.