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

Why does php start with variables?

552


What is $this in php?

537


What are the characteristics of php variables?

527


What are getters and setters php?

547


Why do we show php code in browser?

514






What was the old name of php?

963


What does session start do in php?

509


Why session is required?

526


What is the function to count elements in an array in PHP?

627


How to get no. of rows using MYSQL function?

568


What is form submission?

547


What does echo mean in php?

558


How to create a web form?

554


What sized websites have you worked on in the past?

539


Why is php so popular?

520