offsetSet(1, 'orange'); print_r($arrayObj); ?>
ArrayObject Object ( [0] => apple [1] => orange [2] => cherry )
offsetSet('name', 'John'); $arrayObj->offsetSet('age', 25); var_dump($arrayObj); ?>
object(ArrayObject)#1 (2) { ["name"]=> string(4) "John" ["age"]=> int(25) }In this example, we created an empty array object and used the offsetSet method to add two key-value pairs to it - 'name' with a value of 'John', and 'age' with a value of 25. This method is part of the PHP's Standard PHP Library (SPL) that provides a collection of tools for working with data structures like arrays and objects.