$arr = new ArrayObject([1, 2, 3]); $arr->append(4); // Resulting array: [1, 2, 3, 4]
$arr = new ArrayObject([1, 2, 3]); $arr->append(4, 5); // Resulting array: [1, 2, 3, 4, 5]In both examples, we create a new instance of the ArrayObject class and pass an initial array as an argument. Then, we use the append() method to add one or more elements to the end of the array. The resulting array is returned and can be assigned to a variable or printed directly. The ArrayObject class is part of the PHP Standard Library, which is included in all PHP installations by default.