Ds\Sequence::set

(PECL ds >= 1.0.0)

Ds\Sequence::set β€” Updates a value at a given index

Опис

abstract public Ds\Sequence::set(int $index, mixed $value): void

Updates a value at a given index.

ΠŸΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΈ

index

The index of the value to update.

value

The 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
)
οΌ‹add a note

User Contributed Notes

There are no user contributed notes for this page.