Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
queue
pop
communitycreator

What is Ds\Queue::pop() in PHP?

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The Queue::pop() function in PHP returns the element that is available at the front of the queue, and removes that element from the queue.

Figure 1 shows the visual representation of the Queue::pop() function.

Figure 1: Visual representation of Queue::pop() function

Syntax

queue_name->pop()
## where the queue_name is the name of the queue

Parameter

This function does not require a parameter.

Return value

This function returns the element that is available at the front of the queue and removes that element from the queue.

Example

<?php
$queue = new \Ds\Queue();
#sending the list of elements 
$queue->push(1,3,5,2,0);
echo("Queue before pop");
print_r($queue);
######output######
#Queue before pop : 1->3->5->2->0
echo("Queue after pop");
$queue->pop()
print_r($queue);
######output######
#Queue after pop : 3->5->2->0
?>	

RELATED TAGS

php
queue
pop
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring