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
Is age nominal or ordinal?
What does it mean when it says the csrf token is invalid?
Write a program to get second highest number in an array using php?
What is difference between Method overriding and overloading in PHP?
What is move_uploaded_file in php?
What is the difference between php and java?
What is difference between get and post in php?
How to set cookies?
What are the special characters you need to escape in double-quoted stings?
Which is faster for or foreach?
What is include in php?
What is the difference between Split and Explode in PHP?
Tell me whether it is possible to share a single instance of a memcache between multiple php projects?
Explain about the connective abilities of the PHP?
Name some of the functions in php.