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 how can we determine whether a variable is set?
Explain converting an object?
Write a program to find no of days between two dates in php?
Which function would you use to replace a record in a database in php?
Explain the value of the variable input is a string 1,2,3,4,5,6,7. How would you get the sum of the integers contained inside input?
Why framework is used in php?
What are the different opening and closing tags available in PHP?
Hi this is amul jani here, i complied my graduation in B.com stream.. but as career i looking for PHP language.. to get shape my career. so is that possible to enter in IT world.. for me how much scope of develop my career in this field.. amul jani
How to get no of arguments passed to a PHP Function?
Is null in php?
What is meant by variable variables in php?
What is htaccess in php?
How long do php sessions last?
What is the use of the function 'imagetypes()'?
How can we set and destroy the cookie in php?