(PHP 5 >= 5.3.0)
The SplStack class provides the main functionalities of a stack implemented using a doubly linked list.
Sandro Alves Peres (2013-06-12 12:04:13)
<?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
*/
?>