what is the diffrence between for and foreach?
Answer Posted / anuradha
foreach sort of asbtracts away some of the complexity and is
usually easier. I use this whenever I don't need to know the
numeral index of the array or $key => $value won't provide
me with it.
for is the older C style where you must first perform a
count() so you know how many iterations the loop requires.
It is useful when you need to know the index, or to count
backwards or step through in different groups.
| Is This Answer Correct ? | 1 Yes | 3 No |
Post New Answer View All Answers
A process is identified by a unique___
What is difference between isset and empty in php?
How to create connection in php?
What are the different types of statements that are present in php?
What are default session time and path?
Is php closing tag necessary?
How to reset/destroy a cookie?
How to track no of user logged in?
How a constant is defined in a php script?
Which is true about the singleton design pattern?
What is isset post?
What is the difference between htmlentities() and htmlspecialchars()?
Can we extend two classes in php?
Write a select query that will be displayed the duplicated site name and how many times it is duplicated?
Why is used in php?