PHP Ds\Queue clear() Function Last Updated : 09 Nov, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The Ds\Queue::clear() Function in PHP is used to clear all of the elements from a Queue instance. This function just clears the instance without deleting it. Syntax: void public Ds\Queue::clear ( void ) Parameters: This function does not accepts any parameters. Return Value: This function does not returns any value. Below programs illustrate the Ds\Queue::clear() function in PHP: Program 1: 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 ( ) Program 2: PHP <?php // Declare new Queue $q = new \Ds\Queue(); // Add elements to the Queue $q->push("Geeks"); $q->push("for"); $q->push("Geeks"); 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] => Geeks [1] => for [2] => Geeks ) Queue after clearing: Ds\Queue Object ( ) Reference: http://php.net/manual/en/ds-queue.clear.php Comment More infoAdvertise with us Next Article PHP | DsStack clear() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_queue Similar Reads PHP DsQueue clear() Function The Ds\Queue::clear() Function in PHP is used to clear all of the elements from a Queue instance. This function just clears the instance without deleting it. Syntax: void public Ds\Queue::clear ( void ) Parameters: This function does not accepts any parameters. Return Value: This function does not r 1 min read PHP | DsStack clear() Function The Ds\Stack::clear() function of PHP is used to remove all elements from a Stack and clear it. This function simply removes all of the elements from the Stack but not completely deletes it. It just empties it. Syntax: void public Ds\Stack::clear ( void ) Parameters: This function does not accept an 2 min read PHP | DsDeque clear() Function The Ds\Deque::clear() function is an inbuilt function in PHP which is used to clear the Deque by removing all elements from the Deque. Syntax: public Ds\Deque::clear( void ) : void Parameters: This function does not accepts any parameter. Return Value: This function does not return any Value. Below 2 min read PHP | DsVector clear() Function The Ds\Vector::clear() function is an inbuilt function in PHP which is used to clear the vector elements by removing all the elements from the vector. Syntax: void public Ds\Vector::clear( void ) Parameters: This function does not accept any parameter. Return Value: This function does not return any 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 | DsCollection clear() Function The Ds\Collection::clear() function is an inbuilt function in PHP which is used to remove all values from the collection. Syntax: Ds\Collection::clear( void ) Parameters: This function does not accepts any parameters. Return Value: This function does not return any value. Below programs illustrate t 1 min read Like