20 public function push($elem) {
21 $this->stack[] = $elem;
28 public function pop() {
30 $last_index =
count($this->stack) - 1;
31 $elem = $this->stack[$last_index];
32 unset($this->stack[$last_index]);
33 $this->stack = array_values($this->stack);
44 public function top() {
46 return $this->stack[
count($this->stack) - 1];
57 return !(bool)
count($this->stack);
62 $this->stack = array();
70 return count($this->stack);
75 echo
"<pre>" . print_r($this->stack, 1) .
"</pre>";