SPHPlayground API
SPHPlayground
sphplayground sphplayground

Standard library: Datastructures

The Standard PHP Library (SPL) provides a set of standard data structures, and there is also a PECL package Efficient data structures for PHP 7 available for some systems. SPHP framework introduces a few extensions and add-ons to this set.

Stack: a (LIFO) data structure

A stack represents a last in, first out (LIFO) data structure. [1] The ArrayStack implements the Stack interface. This interface defines following methods.

Synopsis
interface Stack
Pushes an item onto the top of the stack
public push(mixed $value):static
Removes the item at the top of the stack and returns that item as the value
public pop():mixed
Observes the top-most element without removing it from the stack
public peek():mixed
Determine if the stack is empty or not
public isEmpty():bool