Last active
August 24, 2016 13:24
-
-
Save zachflower/7fe5f231a56761b4f73a to your computer and use it in GitHub Desktop.
PHP implementation of a stack.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// http://www.cplusplus.com/reference/stack/stack/ | |
class Stack { | |
private $_stack = array(); | |
public function size() { | |
return count($this->_stack); | |
} | |
public function top() { | |
return end($this->_stack); | |
} | |
public function push($value = NULL) { | |
array_push($this->_stack, $value); | |
} | |
public function pop() { | |
return array_pop($this->_stack); | |
} | |
public function isEmpty() { | |
return empty($this->_stack); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment