what is the diffrence between for and foreach?
Answer Posted / p parimi
For can be used to run statements for a fixed number of
times, foreach can be used to run statements for dynamically
generated arrays(may be result of database query).We can
also used for loop for dynamically generated array(may be
result of database query) but foreach is the ideal way to
iterate dynamic array. The reason behind this, we don't know
the index of array as it may be associate result from
database query. So if we use foreach than it will iterate
the result one by one.
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What is difference between strstr() and stristr() in PHP?
What language is php written in?
How could I install codeignitor ?
What is zend studio for?
What is use of mysqli_query in php?
Explain the difference between isset() and empty()?
What is difference between php and html?
How to get number of days between two given dates using PHP?
What does $_env mean?
Which method do you follow to get a record from a million records? (Searching not from database, from an array in php)?
What is meant by an associative array?
What is binary safe string?
How is it possible to propagate a session id?
Where php language is used?
How does csrf attack work?