The ArrayIterator::offsetSet() function is an inbuilt function in PHP which is used to set the value for an offset.
void ArrayIterator::offsetSet( mixed $index, mixed $newval )
Parameters: This function accepts two parameters as mentioned above and described below:
- $index: This parameter holds the index to set the offset.
- $newval: This parameter holds the new value to store at given index.
Return Value: This function does not return any value.
Below programs illustrate the ArrayIterator::offsetSet() function in PHP:
ArrayIterator Object ( [storage:ArrayIterator:private] => Array ( [a] => 4 [b] => 2 [g] => Geeks [d] => 6 [e] => 1 [f] => 9 ) )
ArrayIterator Object ( [storage:ArrayIterator:private] => Array (  => for  => GeeksforGeeks  => Science  => Geeks  => Portal  => Computer ) )
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.