note 63220 deleted from function.array-push by joey
| From: | joey@php.net | Date: | Sun, 30 Oct 2011 07:04:38 +0000 |
| Subject: | note 63220 deleted from function.array-push by joey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184228@lists.php.net to get a copy of this message | ||
Note Submitter: krristaps at inbox dot lv
----
Here is the smallest chunk of php code describing data structure called stack:
<?php
class stack{
var $memory=array();
function push($value){
$this->memory[]=$value;
}
function pop(){
$count=$this->count();
if ($count){
$value=$this->memory[$count-1];
unset($this->memory[$count-1]);
return $value;
}
else return false;
}
function count(){
return count($this->memory);
}
};
?>