/** * PHP Class for queue * @author yangqijun@live.cn * @copyright Datafrog Beijingbei Ltd. 2011 -07-25 * * classQueue { Public$length= A;//default queue, equivalent to initialize queue Public$queue=Array();//If String like this ' 22,23,24 ' convert to array to do queue Public$delimiter=','; function__construct($queue=array()) {$this->queue=$queue; }/** * @desc start queue * @param String $param New Queue element */ Public functionrun($param) {if(!is_array ($this->queue)) {$this->strtoque ();//Treat an array as a queue}$currentlength=$this->countqueue ();//count the queue LengthEcho$currentlength;Echo$this->length.'
';if($currentlength<$this->length&&$this->length>0) {$this->queadd ($param); }Elseif($this->length==0)//If it is an empty queue, the queue is initialized to the input queue{$param=Empty($param)?0:$param;$this->queue[]=$param; }Else{ for($i=0;$i<$currentlength-$this->length-1;$i++)//Queue more than the specified queue, to delete the first element in order to be queued{$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 * / Public functionstrtoque(){if(Empty($this->queue)) {$this->queue=Array(); }Else{$this->queue=explode ($this->delimiter,$this->queue); } }/** * Insert $node into queue * @param string $node */Private functionqueadd($node){Array_push ($this->queue,$node);$this->countqueue (); }Private functionqueremove(){$node= Array_shift ($this->queue);$this->countqueue ();return$node; }Private functioncountqueue(){$currentlength= Count ($this->queue);return$currentlength; } function__destruct() {unset($this->queue); } }//example$str=' 88|89|90|56|23|45|69|23|20|100 ';$obj=NewQueue ($str);$obj->length=8;//Queue element length$obj->delimiter='|';//If the queue is a string, the element's immediate delimiter is |$a=$obj->run (' the ');//elements to be added to the queue$a=$obj->run (' the ");$a=$obj->run (' the ' ");$a=$obj->run (' 94 '); Print_r ($a);?>
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the PHP queue class, including PHP, queue content, I hope that the PHP tutorial interested in a friend helpful.