Ds\Stack::peek
PHP function
Edit on GitHub ✎
(PECL ds >= 1.0.0)
Returns the value at the top of the stack
Description
Ds\Stack::peek(): mixed
Returns the value at the top of the stack, but does not remove it.
Parameters Parameters
Return Values
The value at the top of the stack.
Errors/Exceptions
UnderflowException if empty.
Examples
Ds\Stack::peek() example
php
<?php
$stack = new \Ds\Stack();
$stack->push("a");
$stack->push("b");
$stack->push("c");
var_dump($stack->peek());
?>The above example will output something similar to:
output
string(1) "c"