The function deletes the last element in the array. Delete a function at the end to add one or more elements to the end of the array of the first parameter (in the stack), and then return the length of the new array. Purpose: mainly test the array functions.
Array_pop array_push
The array_pop () function deletes the last element in the array. Delete the array_push () function to add one or more elements to the end of the array of the first parameter (in the stack), and then return the length of the new array. This function is equivalent to calling $ array [] = $ value multiple times. End of plug-in 1
Array_unshift array_shift
The array_shift () function deletes the first element in the array and returns the value of the deleted element. The first array_unshift () function is used to insert new elements into the array. The value of the new array is inserted at the beginning of the array. Insert first
Reset end
The reset () function points the internal pointer to the first element in the array and outputs it. The end () function points the internal pointer of the array to the last element and returns the value (if successful) of the element ).
Implementation code:
Queue, $ value);}/** (tail) team-OUT **/public function removeLast () {return array_pop ($ this-> queue);}/** (header) queue **/public function addFirst ($ value) {return array_unshift ($ this-> queue, $ value);}/** (header) departure **/public function removeFirst () {return array_shift ($ this-> queue);}/** clear queue **/public function makeEmpty () {unset ($ this-> queue);}/** get the column header **/public function getFirst () {return reset ($ this-> queue );} /** get the end of a column **/public function getLast () {return end ($ this-> queue);}/** get length **/public function getLength () {return count ($ this-> queue );}}
The above describes how to use php to implement a two-way queue code instance. For more information, see other related articles in the first PHP community!