Movatterモバイル変換


[0]ホーム

URL:


    SplQueue »
    « SplDoublyLinkedList::valid

    The SplStack class

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

    Introduction

    The SplStack class provides the main functionalities of a stack implemented using a doubly linked list by setting the iterator mode toSplDoublyLinkedList::IT_MODE_LIFO.

    Class synopsis

    classSplStackextendsSplDoublyLinkedList {
    /* Inherited constants */
    /* Inherited methods */
    }

    Examples

    Example #1SplStack example

    <?php
    $q
    = newSplStack();
    $q[] =1;
    $q[] =2;
    $q[] =3;
    foreach (
    $qas$elem) {
    echo
    $elem."\n";
    }
    ?>

    The above example will output:

    321

    Found A Problem?

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

    User Contributed Notes2 notes

    lsroudi at gmail dot com
    11 years ago
    the SplStack is  simply a SplDoublyLinkedList with  an iteration mode IT_MODE_LIFO and IT_MODE_KEEP
    lincoln dot du dot j at gmail dot com
    8 years ago
    <?php//SplStack Mode is LIFO (Last In First Out)$q= newSplStack();$q[] =1;$q[] =2;$q[] =3;$q->push(4);$q->add(4,5);$q->rewind();while($q->valid()){    echo$q->current(),"\n";$q->next();}?>Output54321
    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