Movatterモバイル変換


[0]ホーム

URL:


    SplDoublyLinkedList::offsetUnset »
    « SplDoublyLinkedList::offsetGet

    SplDoublyLinkedList::offsetSet

    (PHP 5 >= 5.3.0, PHP 7, PHP 8)

    SplDoublyLinkedList::offsetSetSets the value at the specified $index to $value

    Description

    publicSplDoublyLinkedList::offsetSet(?int$index,mixed$value):void

    Sets the value at the specifiedindex tovalue.

    Parameters

    index

    The index being set. Ifnull, the next value will be added after the last item.

    value

    The new value for theindex.

    Return Values

    No value is returned.

    Errors/Exceptions

    ThrowsOutOfRangeException whenindex is out of bounds or whenindex cannot be parsed as an integer.

    Found A Problem?

    Learn How To Improve This PageSubmit a Pull RequestReport a Bug
    add a note

    User Contributed Notes1 note

    chanel at lipski-development dot de
    7 years ago
    How to change elements of a SplDoublyLinkedList<?phpfunctionchange_elements($list,$old_index,$new_index){$tmp1=$list->offsetGet($old_index);$tmp2=$list->offsetGet($new_index);$list->offsetSet($old_index,$tmp2);$list->offsetSet($new_index,$tmp1);}$list=newSplDoublyLinkedList();$list->push("A");$list->push("B");$list->push("C");/*OUTPUTABC*/change_elements($list,0,1);/*OUTPUTBAC*/?>
    add a note
    To Top
    and to navigate •Enter to select •Esc to close •/ to open
    PressEnter without selection to search using Google

    [8]ページ先頭

    ©2009-2025 Movatter.jp