Chapter

Adding Elements

From ComputerScienceOne by Dr Chris Bourke

Concepts

  1. 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.

  2. 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

Adding Elements | ComputerScienceOne | Bifalgorithm | Bifalgorithm