(PHP 5, PHP 7)
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.
Nu este întoarsă nici o valoare.
Notă:
The
offset
parameter will be set toNULL
if another value is not available, like in the following example.<?php
$arrayaccess[] = "first value";
$arrayaccess[] = "second value";
print_r($arrayaccess);
?>Exemplul de mai sus va afișa:
Array ( [0] => first value [1] => second value )
Notă:
This function is not called in assignments by reference and otherwise indirect changes to array dimensions overloaded with ArrayAccess (indirect in the sense they are made not by changing the dimension directly, but by changing a sub-dimension or sub-property or assigning the array dimension by reference to another variable). Instead, ArrayAccess::offsetGet() is called. The operation will only be successful if that method returns by reference, which is only possible since PHP 5.3.4.