Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed PHP Arrays and Control Structures!

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
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 up-
Keegan Kemp
1,986 Points1 Answer
-
Oliver Whittaker
7,054 Points1 Answer
-
Lylie Lylie
10,872 Points2 Answers
-
Chaitanya Tambe
2,970 Points1 Answer
-
Charles Loehle
8,443 Points1 Answer
-
Fuzz Abus
3,106 PointsThe majority of this course is just listening to this lady speak on and on. Barely any self practice or application.
Posted by Fuzz AbusFuzz Abus
3,106 Points2 Answers
-
Piyush Patel
17,253 PointsWhy does my workspace never show me the desired result?
Posted by Piyush PatelPiyush Patel
17,253 Points4 Answers
-
Ryan Lucas
6,946 Points3 Answers
-
Dhruv Kapoor
2,902 PointsWhen we use foreach loop to create $key=$item, how is $key storing numerical values and how are $item being initialised
Posted by Dhruv KapoorDhruv Kapoor
2,902 Points1 Answer
-
Eric C
7,998 Pointsmy output for the exercise functions correctly but I still have \n\n\n\n\n\n\ echoing in the middle
Posted by Eric CEric C
7,998 Points1 Answer
-
Hazem mosaad
15,384 Pointsfor looping challenge task it work in my wamp server and when try it in the site its appear Oops! It looks like Task 1 !
Posted by Hazem mosaadHazem mosaad
15,384 Points2 Answers
View all discussions for this video
Related 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