The PHP implementation Queue class is for reference only
Queue= $queue;} /** * @desc Start queue * @param String $param new Queue element */public function run ($param) {if (!is_array ($this->qu Eue) {$this->strtoque ();} $currentlength = $this->countqueue (); Count the queue Lengthif ($currentlength < $this->length&& $this->length>0) {$this->queadd ($ param);} else if ($this->length=0) {$this->queue[]= $param;} else {$this->queremove (); $this->queadd ($param);} return $this->queue;} /** * string like the "22,23,24" convert to array to do queue * @param string $string * @param string $delimiter */publi C function Strtoque () {if (Empty ($this->queue)) {$this->queue=array ();} else {$this->queue=explode ($this->delimiter, $this->queue);}} /** * Insert $node into queue * @param string $node */private function Queadd ($node) {Array_push ($this->queue, $node); $t His->countqueue ();} Private Function Queremove () {$node = Array_shift ($this->queue); $this->countqueue (); return $node;} Private Function CountqueuE () {$currentlength = count ($this->queue); return $currentlength;} function __destruct () {unset ($this->queue);}} Example $str = "; Array (); $obj =new Queue ($str); $obj->length=8; Queue element length $obj->delimiter= ' | '; If the queue is a string, the element's immediate delimiter is | $a = $obj->run (' 91 '); The element to add to the queue $a= $obj->run (' 92 '); $a = $obj->run (' 93 '); $a = $obj->run (' 94 '); Print_r ($a);?>