Chapter
Adding Elements
From ComputerScienceOne by Dr Chris Bourke
Concepts
- How can you iterate through an array using foreach?
"For each key value pair:\n\nforeach($arr as $key => $val) {\n\nprint \"$key maps to $val\n\n\";\n\n}\n\nThis syntax gives you access to both the key and the value for each element in the array $arr.
- How can you add elements to an array?
"You can easily add elements to an array by providing an index and using the assignment operator as in the previous examples. There are also several functions PHP defines that can insert elements to t