PHPBuilder - Stack class

RSS Twitter

Stack class

by: Andrej Kvasnica
October 19, 2000

Version: 1.0

Type: Class

Category: Other

License: GNU General Public License

Description: Simple Stack class, implemented push, pop and simple stack display functions.

// Stack class
// 19-oct-2000
// Andrej Kvasnica, JPD development Ltd.
// v1.0

class Stack
	var $vals;
	var $amount;
	var $maximum;

	function Stack() {
	function push($number){
		if ($this->maximum > $this->amount){
		} else {
		return $this->amount;
	function pop(){
		if ($this->amount){
			return $this->vals[$this->amount];
		} else {
			die("stack empty");
	function display($before,$after,$ending){
		for ($i=0; $i < $this->amount; $i++) {
			echo $before.$this->vals[$i].$after;
		echo $ending;
	function size(){
		return $this->amount;
	function maxsize(){
		return $this->maximum;

Comment and Contribute

Your comment has been submitted and is pending approval.

Andrej Kvasnica



(Maximum characters: 1200). You have characters left.