The Ds\Deque::filter() function is an inbuilt function in PHP which is used to filter out the elements from the deque based on the operation defined in the callback function.
public Ds\Deque::filter( $callback ) : Ds\Deque
Parameters: This function accepts single parameter $callback which is the callback function which contains the definition of filter to the elements from the deque.
Return Value: This function returns a new Deque which contains all the values for which callback returns True or all values that convert to True if a callback was not provided.
Below programs illustrate the Ds\Deque::filter() function in PHP:
Elements in the deque are Ds\Deque Object (  => 1  => 2  => 3  => 4  => 5  => 6 ) Ds\Deque Object (  => 2  => 4  => 6 )
Elements in the deque are Ds\Deque Object (  => 10  => 20  => 3  => 40  => 50  => 6 ) Ds\Deque Object (  => 3  => 6 )
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.