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
How to remove duplicate values from array using php?
What are the two main string operators?
What are the differences between GET and POST methods?
What is super keyword in php?
Do I need apache for php?
What is session cookies php?
Which will check if a function exists?
How to get no. of rows using MYSQL function?
How to track user logged out or not? When user is idle?
Where is php code written?
What is uniqid php?
Is empty array php?
Can php use gettext?
How do you execute a php script from the command line?
What is the use of the function 'imagetypes()'?