$fruits = new ArrayObject(array('apple', 'banana', 'cherry')); echo $fruits->0; // Output: apple echo $fruits->1; // Output: banana echo $fruits->2; // Output: cherry
$fruits = new ArrayObject(array('apple', 'banana', 'cherry')); $fruits->append('date'); echo $fruits->3; // Output: dateIn this example, we added a new element to the ArrayObject using the append() method. The new element 'date' was added to the end of the array. This package belongs to the PHP Standard Library, which means that it is included in PHP by default and does not require any additional installation or setup.