(PECL ds >= 1.0.0)
Ds\Sequence::set β Updates a value at a given index
Updates a value at a given index.
indexThe index of the value to update.
valueThe new value.
ΠΠ΅ ΠΏΠΎΠ²Π΅ΡΡΠ°Ρ Π·Π½Π°ΡΠ΅Π½Ρ.
OutOfRangeException if the index is not valid.
ΠΡΠΈΠΊΠ»Π°Π΄ #1 Ds\Sequence::set() example
<?php
$sequence = new \Ds\Vector(["a", "b", "c"]);
$sequence->set(1, "_");
print_r($sequence);
?>ΠΠΎΠ΄Π°Π½ΠΈΠΉ Π²ΠΈΡΠ΅ ΠΏΡΠΈΠΊΠ»Π°Π΄ Π²ΠΈΠ²Π΅Π΄Π΅ ΡΠΎΡΡ ΡΡ ΠΎΠΆΠ΅ Π½Π°:
Ds\Vector Object
(
[0] => a
[1] => _
[2] => c
)
ΠΡΠΈΠΊΠ»Π°Π΄ #2 Ds\Sequence::set() example using array syntax
<?php
$sequence = new \Ds\Vector(["a", "b", "c"]);
$sequence[1] = "_";
print_r($sequence);
?>ΠΠΎΠ΄Π°Π½ΠΈΠΉ Π²ΠΈΡΠ΅ ΠΏΡΠΈΠΊΠ»Π°Π΄ Π²ΠΈΠ²Π΅Π΄Π΅ ΡΠΎΡΡ ΡΡ ΠΎΠΆΠ΅ Π½Π°:
Ds\Vector Object
(
[0] => a
[1] => _
[2] => c
)