Chapter
Iteration
From ComputerScienceOne by Dr Chris Bourke
Concepts
- How can you extract array keys and values and compare arrays in PHP?
"$keys = array_keys($arr);\n\n$vals = array_values($arr);\n\nprint_r($keys);\n\nprint_r($vals);\n\nwould print Array ( [0] => foo [1] => 4 [2] => 0 [3] => baz ) Array ( [0] => 5 [1] => bar [2] => 3.14
- How can you iterate over indexed and associative arrays in PHP?
"If we have an array in PHP that we know is 0-indexed and all elements are contiguous, we can use a normal for loop to iterate over its elements by incrementing an index variable.\n\nfor($i=0; $i<coun