PHP Foreach Loop Tutorial

Upgrade your Clever Techie learning experience:

UPDATE! (9/13/19) New features and improvements for Clever Techie Patreons:

1. Download full source code with detailed comments – easy to learn and understand code
2. Weekly source code file updates by Clever Techie – every time I learn new things about a topic I will add it to the source file and let you know about the update – keep up with the latest coding technologies
3. Library of custom Clever Techie functions with descriptive, easy to understand comments – skyrocket coding productivity, code more efficiently by using Clever library of custom re-usable functions
4. Syntax code summary – memorize and review previously learned code faster
4. Organized file structure – access all Clever Techie lessons, source code, graphics, diagrams and cheat sheet from a single workspace – no more searching around for previously covered material and source code – save enormous amount of time and effort
5. Outline of topics the source file covers – fast review of all previously learned coding lessons
6. Access to all full HD 1080p videos with no ads
7. Console input examples – interactive examples that make it easier to understand and learn coding
8. Access to updated PHP Programming Book by Clever Techie
9. Early access to Clever Techie videos

Subscribe to Clever Techie patreon:

We learn how the syntax of PHP foreach loop works which is used to loop through associative arrays in PHP. We also explore an alternative syntax of writing the foreach loop as well as modifying the values inside the loop directly using values by reference.

Hey guys, I’m now using Patreon to share improved and updated video lesson material. For a small fee you can access all the downloadable files from this lesson (source code, icons & graphics, cheat sheets) and everything else included in the video from the Patreon page. Additionally, you will get access to ALL Clever Techie videos in HD format with no ads. Thank you so much for supporting Clever Techie 🙂

Download this video’s files here:

( You also get access to ALL source code and any downloadable content of ALL Clever Techie videos, as well as access to ALL videos in HD 1080p quality format with all video ads removed! )


( Website ) – PHP, JavaScript, WordPress, CSS, and HTML tutorials in video and text format with cool looking graphics and diagrams.

( YouTube Channel )

( Google Plus ) – clever techie video tutorials.

( Facebook )

( Twitter )



Xem thêm bài viết khác:

29 thoughts on “PHP Foreach Loop Tutorial”

  1. Thank You Clever Techie, after years of coding, this is the very first time I see someone explain associative arrays and loops in such an easy to understand examples.

  2. I have been watching your tutorials and I got to say you are "KILLING IT!". From all the videos I enjoyed yours. All other youtubers that provide tutorials doesn't have anything on you. I go to some of the videos and I am left disappointed. You have put a lot of work into them. It reminds me of me when I was with Instinet, IBM, Microsft, etc when I would create handbooks with a lot of details and images. Keep up the go work. Sometimes I don't have time to go through a PHP book and your videos on the subject speeds my learning process. You videos and a good book helps my learning. I especially love the 100 PHP functions series. I let your videos run all day, like someone does for music. This way it can go into the sub-conscience mind.

  3. Hi thanks for this useful tutorial. May i ask, from your example above, how can we store the $name from the $animal array into a variable and we want to store it in string? Thanks for your reply in advance sir

  4. Hi ,
    I enjoyed your tutorial. While trying it out, to use it to populate a <select><options> form element, so that selecting one of the options in a form , I can insert that selection into a database table. I was shocked to see that only one option, the last item in the array, was getting inserted into the table, regardless of which option is selected!
    Any idea why? Is it wrong to use the foreach loop in this manner?

  5. Thanks for the explanation but after you unset($numbers); it will give an error if you want to print it after this function ,, because $numbers is unset now

  6. I watched this and did the exact same thing but for some reason it only multiplies my last number. The coding is correct so what am i doing wrong?


Leave a Comment