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
Please explain is it possible to use com component in php?
How can you make a connection with mysql server using php?
Which php function will attach one file to another?
How can you retrieve a cookie value?
What are the differences between echo and print?
How can we enable error reporting in php?
Explain how is it possible to cast types in php?
What is php glob?
Is java is better than php?
Is php procedural or oop?
What is htaccess in php?
When are you supposed to use endif to end the conditional statement?
Explain what does the function get_magic_quotes_gpc() means?
A process is identified by a unique___
What is the correct syntax of mail() function in php?