The Queue::count()
function in PHP returns the number of elements in a queue. In short, this function is used to get the current size of the queue.
Figure 1 shows the visual representation of the Queue::count()
function.
queue_name->count()
## where the queue_name is the name of the queue
This function does not require a parameter.
This function returns the number of elements in the queue because it is used to get the current size of the queue.
<?php$queue1 = new \Ds\Queue();#sending the list of elements$queue->push(1,3,5,2,0);echo("Queue1 has elements:");echo($queue1->count());######output#######Queue1 has elements : 5$queue2 = new \Ds\Queue();echo("Queue2 has elements:");echo($queue2->count());######output#######Queue2 has elements : 0?>