what is the diffrence between for and foreach?
Answer Posted / tarsem kurra
foreach is used to iterate over arrays and for loop is used
to run statement for number of times and there is another
major difference is in foreach you want to execute statement
which comes from an database with id which is
autoincremented and you run for loop over it and suppose in
the mean time i delete 3rd rows i.e. 3rd id than what will
this loop stops working but not in foreach and foreach is
the faster than for loop..
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
How to access a global variable inside a function?
Where is session value stored?
Is laravel easy to learn?
What is the difference between single-quoted and double-quoted strings in php?
What does the unlink() function mean?
How does the identity operator ===compare two values in PHP?
Who is known as the father of php?
What is the interface in php?
Which is better get or post method?
How to create an array from php string?
What do you mean range() in php?
Do you know what is the difference between mysql_fetch_object() and mysql_fetch_array()?
Tell me how stop the execution of a php scrip?
what is CURL?
How is php different from other languages?