for
Statement (Cont.)
The foreach Statement
The foreach statement is used to loop through arrays. |
|
For every loop, the value of the current array element is assigned to $value (and the array pointer is moved by one)—so on the next loop, you’ll be looking at the next element.
|
|
array([mixed $...])
creates an array and returns an array of the parameters.
The parameters can be given an index with the =>
operator, whose syntax index => values
$class = array( 0 => "Freshman", 1 => "Sophomore", 2 => "Junior", 3 => "Senior" );
Who’s phoning radio stations to warn of traffic jams? Who in their right mind gets stuck and thinks, “Get me the phone, I must warn the others. It’s too late for me…” — Michael McIntyre’s |