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
Is php still used?
Which variable declarations within a class is invalid in php?
What are the features and advantages of object-oriented programming in php?
What is difference between strstr() and stristr()?
Why do we use query?
Distinguish between urlencode and urldecode?
What are the ways to include file in php?
What is the difference between rest and soap?
What is $_session in php?
What does php mean?
What is helper library?
What is the difference between md5(), crc32() and sha1() crypto on php?
Is array empty php?
What is the difference between runtime exception and compile time exception?
What is the delimiter syntax is PHP's default delimiter syntax