What are the differences between the for
loop and the foreach
loop in PHP?
A "for" loop gives you an incrementing number (in its most common use) which you can use any way you like.
"foreach" is a special construct made for looking at successive members of an array.
As an example, you can use a "for" loop to create something that does what "foreach" does. But foreach does that with less required code.