-
-
Save mikemadisonweb/f721661d0ff1b9280d99b076a27eba55 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