Teacher Russell16,869 Points
random fun with arrays
Can someone offer someone offer some explanation of what's happening in this video around 3:00? Too many big changes too quickly and I can't quite figure out why or what:) Thank you!
Jonathan GrieveTreehouse Moderator 85,725 Points
Usually, when you're struggling because it's seemingly happening too fast, it's a good time to watch the video again... you might begin to absorb a little more when you know what to expect in the video.
But I'll try to explain what's going on :)
We're basically iterating through an array with PHP and displaying the results in the browser.
get_item_html() might not seem likee it's doing anything much but we're echoing out the results of a function call.
Every time the loop iterates (which means runs a single cycle through the loop) it will return different items from an array. That's what the 4 does in the rand function. It's limiting the display for 4 random items in the array.
<?php get_item_html($id, $catalog[$id]) ?>