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.
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:
Initial Queue: Ds\Queue Object (  => One  => Two  => Three ) Queue after clearing: Ds\Queue Object ( )
Initial Queue: Ds\Queue Object (  => Geeks  => for  => Geeks ) Queue after clearing: Ds\Queue Object ( )
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.