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 nan in php?
What is a model in php?
How do you remove whitespace from the beginning and end of a $string variable?
Tell me how stop the execution of a php scrip?
How to access a specific character in a string using php?
What does $_env means?
What are the types of variables in php?
What is the meaning of a final class and a final method?
What advance thing in php7?
Does php class need constructor?
How to close a session properly?
What is php data type?
Tell me what sized websites have you worked on in the past?
How we get ip address of client, previous reference page etc?
Tell me what is the difference between get and post?