PHP SplQueue::enqueue() Function Last Updated : 23 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The SplQueue::enqueue() function is an inbuilt function in PHP which is used to add the element to the queue. Syntax: void SplQueue::enqueue( $val ) Parameters: This function accepts a single parameter $val which specifies the value for add (enqueue) element. Return Value: This function does not return any value. Below programs illustrate the SplQueue::enqueue() function in PHP: Program 1: php <?php // Create a new empty queue $gfg = new SplQueue(); $gfg[] = 1; // Enqueue element $gfg->enqueue(10); $gfg->enqueue(20); echo $gfg[1] . "\n"; echo $gfg[2] . "\n"; ?> Output: 10 20 Program 2: php <?php // Create some fixed size array $gfg = new SplQueue(); $gfg[] = 1; $gfg[] = 5; $gfg[] = 1; $gfg[] = 11; $gfg[] = 15; $gfg[] = 17; $gfg->enqueue(11); $gfg->enqueue(12); $gfg->enqueue(13); $gfg->enqueue(14); // Print result after enqueue foreach ($gfg as $elem) { echo $elem."\n"; } ?> Output: 1 5 1 11 15 17 11 12 13 14 Reference: https://www.php.net/manual/en/splqueue.enqueue.php Comment More infoAdvertise with us Next Article PHP SplQueue::dequeue() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP SplQueue::dequeue() Function The SplQueue::dequeue() function is an inbuilt function in PHP which is used to dequeues the node from the queue. Syntax: mixed SplQueue::dequeue() Parameters: This function does not accept any parameter. Return Value: This function return the value of the dequeued node. Below programs illustrate th 1 min read PHP SplQueue::__construct() Function The SplQueue::__construct() function is an inbuilt function in PHP which is used to construct a queue which is implemented using a doubly-linked list. Syntax: void SplQueue::__construct(void) Parameters: This function does not accept any parameter. Return Value: This function does not return any val 1 min read PHP DsQueue push() Function The Ds\Queue::push() Function in PHP is used to push or insert values in a PriorityQueue instance. This function can also insert a list of values directly to the Queue. Syntax: void public Ds\Queue::push($value1, $value2, .... $valueN) Parameters: This function accepts a list of values separated by 1 min read PHP DsQueue pop() Function The Ds\Queue::pop() Function in PHP is used to remove and return the value present at the top of the Queue. In other words, it returns the value present at the front of the Queue and also removes it from the Queue. Syntax: mixed public Ds\Queue::pop ( void ) Parameters: This function does not accept 2 min read PHP SplPriorityQueue current() Function The SplPriorityQueue::current() function is an inbuilt function in PHP which is used to return the current node pointed by the iterator. Syntax: mixed SplPriorityQueue::current() Parameters: This function does not accept any parameter. Return Value: This function returns the value/priority of the cu 1 min read PHP SplPriorityQueue count() Function The SplPriorityQueue::count() function is an inbuilt function in PHP which is used to count the number of elements in the queue. Syntax: int SplPriorityQueue::count() Parameters: This function does not accept any parameters. Return Value: This function returns the number of elements in the queue. Ex 1 min read Like