This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
I've saved the best for last! Foreach loops are my favorite when looping through arrays. You can use foreach loops with any type of array, and your array can have any key value. You can choose to grab just the item value or the key value as well. A foreach loop is a lot like combining the WHILE statement with the each function, only even easier.
DOWNLOAD FILE (list.php)
Documentation
foreach loops will allow you to grab the value and optionally the key, but not the key on its own.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up