Related Articles

Related Articles

PHP | Ds\Deque contains() Function
  • Last Updated : 30 Jul, 2019

The Ds\Deque::contains() function is an inbuilt function in PHP which is used to check the deque contains given values or not.

Syntax:

bool Ds\Deque::contains( $values )

Parameters: This function accepts single or many $values which hold the value to check that value exist in the deque or not.

Return Value: If value exist in the deque then it returns True otherwise returns False.

Below programs illustrate the Ds\Deque::contains() function in PHP:



Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php 
  
// Declare new Deque 
$deque = new \Ds\Deque(['G', 'e', 'e', 'k', 's', 5, 2, 7]); 
  
// Use contains() function to check elements 
// exist in the deque or not 
var_dump($deque->contains('G')); 
      
var_dump($deque->contains('k')); 
      
var_dump($deque->contains('p')); 
      
var_dump($deque->contains(7)); 
      
var_dump($deque->contains('5')); 
      
?> 

chevron_right


Output:

bool(true)
bool(true)
bool(false)
bool(true)
bool(false)

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php 
  
// Declare new Deque 
$deque = new \Ds\Deque(['G', 'e', 'e', 'k', 's', 5, 2, 7]); 
  
// Use contains() function to check elements 
// exist in the deque or not 
var_dump($deque->contains('G', 'e')); 
      
var_dump($deque->contains('k', 'e', 7)); 
      
var_dump($deque->contains('p', '1')); 
      
var_dump($deque->contains(7, 1)); 
      
var_dump($deque->contains('5', 5)); 
      
?> 

chevron_right


Output:

bool(true)
bool(true)
bool(false)
bool(false)
bool(false)

Reference: https://www.php.net/manual/en/ds-deque.contains.php




My Personal Notes arrow_drop_up
Recommended Articles
Page :