PHP Ds\Queue Functions Complete Reference Last Updated : 25 Jan, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report A Queue is a linear data structure that follows a particular order in which the operations are performed. The order of queue is First In First Out (FIFO). Requirements: PHP 7 is required for both extension and the compatibility polyfill. Installation: The easiest way to install data structure by using the PECL extension. pecl install ds Syntax: public Ds\Queue::functionname() Example: Below programs illustrate the Ds\Queue::clear() function in PHP: PHP <?php // Declare new Queue $q = new \Ds\Queue(); // Add elements to the Queue $q->push("One"); $q->push("Two"); $q->push("Three"); echo "Initial Queue: \n"; // Display the Queue print_r($q); // clear the Queue $q->clear(); echo "\nQueue after clearing:\n"; print_r($q); ?> Output: Initial Queue: Ds\Queue Object ( [0] => One [1] => Two [2] => Three ) Queue after clearing: Ds\Queue Object ( ) Complete list of data structure DS\Queue: PHP Ds\Queue Functions Description allocate()Allocate memory for a Queue class instance.capacity()Check the current capacity of a Queue instance.clear()Clear all of the elements from a Queue instance.copy()Create a shallow copy of a particular Queue instance.count()Get the count of elements present in a Queue instance.isEmpty()Whether a particular Queue instance is empty or not.peek()Get the value present at the front of a Queue.pop()Remove and return the value present at the top of the Queue.push()Push or insert values in a PriorityQueue instance.toArray()Convert a Queue into an associative array in PHP. Comment More infoAdvertise with us Next Article PHP DsDeque Functions Complete Reference S Sabya_Samadder Follow Improve Article Tags : Web Technologies PHP PHP-ds_queue Similar Reads PHP DsQueue Functions Complete Reference A Queue is a linear data structure that follows a particular order in which the operations are performed. The order of queue is First In First Out (FIFO). Requirements: PHP 7 is required for both extension and the compatibility polyfill. Installation: The easiest way to install data structure by usi 2 min read PHP DsDeque Functions Complete Reference A deque data structure is used to store the sequence of values in a contiguous memory buffer which grows and shrinks automatically. The deque is the abbreviation of "double-ended queue". Requirements: PHP 7 is required for both extension and the compatibility polyfill. Installation: The easiest way 3 min read PHP intl Functions Complete Reference The Complete list of PHP intl Functions are listed below: Collator PHP collator_asort() FunctionPHP collator_compare() FunctionPHP Collator __construct() FunctionPHP Collator create() FunctionPHP collator_sort_with_sort_keys() FunctionPHP collator_sort() Function IntlCalendar PHP IntlCalendar add() 1 min read PHP Filesystem Functions Complete Reference The Filesystem function is used to access and manipulate filesystem. It is the part of PHP code so no need to install these functions. For accessing the files on the system, the file path will be used. On Unix system, forward slash (/) is used as a directory separator and on Windows platform, both f 4 min read PHP DsPriorityQueue Functions Complete Reference PriorityQueue is similar to a Queue data structure. The elements of the priority queue are pushed into the queue with a given priority. The highest priority element will always been present at the front of the queue. The priority queue is implemented using the max heap. Requirements: PHP 7 is requir 2 min read PHP SplPriorityQueue compare() Function The SplPriorityQueue::compare() function is an inbuilt function in PHP which is used to compare the priority queue elements to place at a particular order in the heap data structure. Syntax: int SplPriorityQueue::compare( mixed $priority1 , mixed $priority2 ) Parameters: This function accepts two pa 2 min read Like