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


Scott James
Scott James
4,298 Points

PHP: Including the Products Array question!


I am working through the Including the Products Array video in the "Build a Simple PHP Application" series, and around the 4min mark, Randy needs to create a new variable so that he can get access to the product id. I understand that with this code: $product_id => $product you are accessing the "key" and "value" but how does it pull the product id when that is in the square brackets after the variable name $products? Would it be that the $products variable is the "key" and the index [102] is classed as the "value"?

Thanks for any help offered. Just trying to make sure that I understand this, because I finally feel like I am getting some where with learning PHP :-D

3 Answers

Scott James
Scott James
4,298 Points

OK. I have moved on to the code challenge, and it has cleared this question up :)

Please Help I am having this problem am I missing something, I can click a shirt it takes me to shirt.php But when I log the shirts.php It's Displaying this error on top of the Image shirts

notice: undefined variable: products_id in c:\xampp\htdocs\shirts.php on line 16