Summary
Keywords
Full Transcript
Loops are simple but there are some important things that you need to be aware of when working with them, such as performance, things to be aware of when working with references, how to break out of nested loops, how to handle infinite loops & so on. Loop is basically a control structure that allows you to execute a block of code or multiple statements N times until a given condition evaluates to false or you manually break out of the loop. In this video, we cover while loops, do-while loops, for loops & foreach loops with examples on iterating over strings, arrays, and so on. SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL 👍 Smash the like button 🤝 Subscribe to the channel & turn the notifications on 💬 Post comments, any feedback is greatly appreciated ⭐ Become a Patreon: https://www.patreon.com/programwithgio THANK YOU! LESSON 1.16 Course Outline - https://github.com/ggelashvili/learnphptherightway-outline Course Playlist - https://www.youtube.com/playlist?list=PLr3d3QYzkw2xabQRUpcZ_IBk9W50M9pe- CHAPTERS 00:00 - Intro 00:15 - While loop 01:05 - Infinite loops 01:32 - Break statement & use-case of an infinite loop 02:05 - Break out of multiple levels of nested loops 02:31 - Continue statement 03:32 - Alternative while loop syntax 03:47 - Do-While loop 04:26 - For loop 05:07 - Multiple expressions within for loop 05:48 - Iterate over strings 06:09 - Iterate over arrays 06:23 - Performance concerns 07:20 - Foreach loop 08:38 - Overwriting array elements using assignment by reference 09:15 - Something to be aware of - variable within the foreach loop is not destroyed 10:30 - Iterate over associative arrays 11:48 - Alternative foreach & for loop syntax
