array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'class.splstack.php', 1 => 'SplStack', ), 'up' => array ( 0 => 'spl.datastructures.php', 1 => 'Datenstrukturen', ), 'prev' => array ( 0 => 'spldoublylinkedlist.valid.php', 1 => 'SplDoublyLinkedList::valid', ), 'next' => array ( 0 => 'class.splqueue.php', 1 => 'SplQueue', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/spl/splstack.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
The SplStack class provides the main functionalities of a stack implemented using a doubly linked list by
setting the iterator mode to SplDoublyLinkedList::IT_MODE_LIFO
.
Beispiel #1 SplStack example
<?php
$q = new SplStack();
$q[] = 1;
$q[] = 2;
$q[] = 3;
foreach ($q as $elem) {
echo $elem."\n";
}
?>
Das oben gezeigte Beispiel erzeugt folgende Ausgabe:
3 2 1