note 112404 deleted from class.splstack by cmb
| From: | cmb@php.net | Date: | Fri, 10 Sep 2021 12:29:20 +0000 |
| Subject: | note 112404 deleted from class.splstack by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216942@lists.php.net to get a copy of this message | ||
Note Submitter: Sandro Alves Peres
----
<?php
# Think of the stack as an array reversed, where the last element has index zero
$stack = new SplStack();
$stack->push('a');
$stack->push('b');
$stack->push('c');
$stack->offsetSet(0, 'C'); # the last element has index zero
$stack->rewind();
while( $stack->valid() )
{
echo $stack->current(), PHP_EOL;
$stack->next();
}
/*
OUTPUT
****************************
C
b
a
*/
?>