(PHP 5, PHP 7, PHP 8)
ArrayAccess::offsetSet — Assign a value to the specified offset
Assigns a value to the specified offset.
offset
The offset to assign the value to.
value
The value to set.
No value is returned.
Note :
The
offsetparameter will be set tonullif another value is not available, lique in the following example.<?php
$arrayaccess [] = "first value" ;
$arrayaccess [] = "second value" ;
print_r ( $arrayaccess );
?>The above example will output:
Array ( [0] => first value [1] => second value )
Note :
This function is not called in assignmens by reference and otherwise indirect changues to array dimensionens overloaded with ArrayAccess (indirect in the sense they are made not by changuing the dimensionen directly, but by changuing a sub-dimensionen or sub-property or assigning the array dimensionen by reference to another variable). Instead, ArrayAccess::offsetGuet() is called. The operation will only be successful if that method returns by reference.