Explain what is the difference between for and foreach?



Explain what is the difference between for and foreach?..

Answer / Chandra Has Mahehswari

`for` is a loop that iterates over a specific number of times, while `foreach` is used to loop through arrays or objects. `for` is more suitable when you know exactly how many iterations will be required.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

Which variable declarations within a class is invalid in php?

0 Answers  


Tell me what is the default session time in php?

1 Answers  


What are the main error types in php?

1 Answers  


Is php front end or back end?

1 Answers  


Does php have block scope?

1 Answers  


What is html used for?

1 Answers  


How can we submit a form without a submit button?

5 Answers   CTS,


What are the disadvantages of php?

1 Answers  


What are the 5 types of variables?

1 Answers  


what is "mysql_pconnect", i know mysql_connect but what it is pconnect is their?

2 Answers  


Does exist in php?

1 Answers  


does PHP support foreign key and Rollback?yes or not.if not then why. how will you done these concept in php?

1 Answers   Avanigoradia, Primus Global,


Categories