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 Basic PHP Website (2018) Listing and Sorting Inventory Items Sorting Array Items

I didn't quite understand why we have to return our $output inside an array in the array_category function?

I'm thinking that it is because if we leave just that: return $output it will return just the title.

1 Answer

You're right. When you return just the $output variable (which has the stored titles from the $sort variable), you're just returning the titles of the items. When it's time to pass the returned value to the get_item_html function, you'd get a dead link since the function is looking for an array with image links to display the array items.