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
Which php global variable is used for uploading a file?
What is var_dump?
What is variable and data type?
What is final in php?
What is the use of is_array() and in_array()?
What is needed to be able to use image function?
How to create a session? How to remove data from a session?
How to get the directory name out of a file path name?
Is php open source?
What is a namespace in php?
What is the string concatenation operator in php?
Where are cookies stored php?
Is laravel an oop?
Write a program to find the factorial of a number in php?
What is xss in php?