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 trialMoritlha Madisha
5,014 PointsLittle confused
Hi all!
I'm a little confused with this statement in this lesson. Please look at my question in the question mark after reading the code. Randy Hoyt
while( $row = $results->fetch(PDO::FETCH_ASSOC)) { $product["sizes"][] = $row["size"]; } //why are we does $row["size"] have size instead of "sizes" like the // $product["sizes"] variable?
2 Answers
Colin Marshall
32,861 PointsEach row only has one size in it. The loop takes all of the sizes available for that shirt and loads them into $product array with the rest of the shirt's details. It loads the array into the "sizes" key for the $product array.
Moritlha Madisha
5,014 PointsThanks Colin. I eventually understood the concept through the exercises. The "size" refers to the column in the table and "sizes" refers to "sizes" key in the product array.