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
Tell me what is needed to be able to use image function?
Is php better than java?
What is new static in php?
What is mean tnq
Explain mysql_error().
Write a program to show the joining of two strings in php?
What is empty php?
Name some of the popular frameworks in php.
How to pass variables and data from php to javascript?
What is http get and post?
Is php 7.0 stable?
How to remove values saved in the current session?
What is $globals php?
How to remove leading and trailing spaces from user input values in php?
How can you create a session in php?