Explain me what is the difference between for and foreach?
Submitted by: Muhammadfor is expressed as follows:
for (expr1; expr2; expr3)
statement
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.
Submitted by: Muhammad
for (expr1; expr2; expr3)
statement
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.
Submitted by: Muhammad
Read Online Internee PHP Developer Job Interview Questions And Answers
Top Internee PHP Developer Questions
☺ | Do you know who is the father of PHP? |
☺ | Tell me how can we create a database using php? |
☺ | Tell me what is use of header() function in php? |
☺ | Tell us what does a special set of tags <?= and ?> do in PHP? |
☺ | How to get second of the current time using date function? |
Top Web Developer Categories
☺ | Bootstrap Interview Questions. |
☺ | Front End Web Developer Interview Questions. |
☺ | Typography Interview Questions. |
☺ | Laravel PHP Developer Interview Questions. |
☺ | Junior Developer PHP Interview Questions. |