Source Code:
(back to article)
<?php // Adding elements to an array $array = ["apple", "banana", "cherry"]; array_push($array, "orange"); // Adds "orange" to the end of the array $array[] = "pear"; // Adds "pear" to the end of the array print_r($array) . PHP_EOL; // Removing elements from an array $animals = ["dog", "cat", "bird"]; unset($animals[1]); // Removes the element with index 1 ("cat") print_r($animals );
Result:
Report an issue