SplStack removes the most recently pushed item first.

SPL Stack

spl_stack.php
<?php
$base = ;
$stack = new SplStack();
$stack->push($base);
$stack->push("review");
$top = $stack->pop();
$next = $stack->top();
$remaining = $stack->count();

echo "base=" . $base . "\n";
echo "top=" . $top . "\n";
echo "next=" . $next . "\n";
echo "remaining=" . $remaining . "\n";
<?php
$base = ;
$stack = new SplStack();
$stack->push($base);
$stack->push("review");
$top = $stack->pop();
$next = $stack->top();
$remaining = $stack->count();

echo "base=" . $base . "\n";
echo "top=" . $top . "\n";
echo "next=" . $next . "\n";
echo "remaining=" . $remaining . "\n";
<?php
$base = ;
$stack = new SplStack();
$stack->push($base);
$stack->push("review");
$top = $stack->pop();
$next = $stack->top();
$remaining = $stack->count();

echo "base=" . $base . "\n";
echo "top=" . $top . "\n";
echo "next=" . $next . "\n";
echo "remaining=" . $remaining . "\n";
last in first out Stacks are useful when the latest item should be processed before earlier items.