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


Please Help Members By Posting Answers For Below Questions

Where to put php files in apache server?

505


What is a php class?

536


How cookies are trported from browsers to servers?

568


How is it possible to parse a configuration file?

505


How to delete an element from an array?

557






Explain object-oriented methodology in php?

580


How can we determine whether a variable is set?

523


Explain soundex() and metaphone().

574


How do we get the current session id?

552


What is call by reference in php?

513


How to pad an array with the same value multiple times?

469


What is api used for?

483


What is the use of nl2br() in php?

574


What is a PHP accelerator?

586


What does the scope of variables means?

582