Sr. PHP Programmer Question:
Explain the syntax for 'foreach' loop in PHP?
Answer:
The foreach statement is used to loop through arrays. For each pass the value of the current array element is assigned to $value and the array pointer is moved by one and in the next pass next element will be processed.
foreach (array as value)
{
code to be executed;
}
foreach (array as value)
{
code to be executed;
}
Previous Question | Next Question |
Why would you use === instead of ==? | Explain the importance of the function htmlentities? |