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!

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


Milos Stankovic
Milos Stankovic
15,691 Points

Function get_item_html works fine without $id argument

I removed $id argument from get_item_html($item):

function get_item_html($item) {
    $output = "<li><a href='#'><img src='". $item['img'] ."' alt='" . $item['title'] ."' /><p>View details</p></a></li>";
    return $output;

Also in index.php and catalog.php files that are using this function:

echo get_item_html($catalog[$id]);

The program works fine without it, so I am wondering why it needs to be there?


3 Answers

Hi Milos,

The id is needed for the href attribute on the link. It's currently # as a placeholder but really needs to link to the details.php page.

Updating this link was omitted from the videos but the video linked to below contains an update in the teacher's notes showing how to update the link and why we need the $id.


Milos Stankovic
Milos Stankovic
15,691 Points


Many thanks! Now it makes sense, I updated my product details links.

Thanks again

Alex Forseth
Alex Forseth
8,017 Points

Why is this information not put in the teachers note in the "random fun with arrays" section? Or in an earlier section?