For and foreach loop in php For and foreach loops are mostly used when working with arrays, but not only that of course. In my other examples, I created a simple snipped to show you the while loop in php, same example can be created with For loop. Scenario We have a small array and