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
What is the difference between static and dynamic websites?
What is escape data in php?
How a variable is declared in php?
How does php session work?
Explain what is the difference between $var and $$var?
What is difference between print and echo in php?
Tell me what does the php error 'parse error in php - unexpected t_variable at line x' means?
What is the purpose of using php?
How to process the uploaded files?
What is basename php?
What happens when submit button is clicked?
What is different types of visibility?
Tell me how would you declare a function that receives one parameter name hello?
What is difference between get and post?
Can I learn php in a month?