Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Basic PHP Website (2018) Listing and Sorting Inventory Items Sorting Array Items

Leigh Maher
Leigh Maher
21,830 Points

Why does the get_item_html have 2 parameters?

In the function that ouputs the html for the catalog pages, it's been set up to take 2 paramentes: $id and $item, but the $id is not referenced in the output code. I don't understand why there's 2 parameters being used here.

// Outputs the HTML for our catalog
function get_item_html($id, $item) {
  $output = "<li><a href='#'><img src='{$item['img']}' alt='{$item['title']}'>View Details</a></li>";
  return $output;
}
    foreach($categories as $id) {
        echo get_item_html ($id, $catalog[$id]);
      }

I've tested it without the $id parameter and it works fine.

Hi Leigh,

Yes!! It's not useful right now. Just go on till the end and you will find why she has included it.