▼ Show 1 Answer

0 votes

for is expressed as follows:

for (expr1; expr2; expr3)


The first expression is executed once at the beginning. In each iteration, expr2 is evaluated. If it is TRUE, the loop continues, and the statements inside for are executed. If it evaluates to FALSE, the execution of the loop ends. expr3 is tested at the end of each iteration.

However, foreach provides an easy way to iterate over arrays, and it is only used with arrays and objects.

Learn More with Madanswer

Related questions

0 votes
asked Jun 23, 2019 in PHP by SakshiSharma