PHP Ds / Vector function contains ()

PHP

Syntax:
bool public DsVector::contains ($values)
Parameters: This function takes one parameter $values, which contains one / many values.Return value:this function returns true if the given value exists , otherwise - false.The following programs illustrate Ds / Vector::containsthe ()function in PHP:Program 1 :  
// Create vector $vector = new DsVector ([1, 2, 3, 4, 5]);  
// Use the contains() function to check
// existence of vector elements var_dump ( $vector -> contains (1)); var_dump ( $vector -> contains (1, 2)); var_dump ( $vector -> contains (10));  
?>
Output:
bool (true) bool (true) bool (false)
Program 2:  
// Create vector $vector = new DsVector ([ "engineer" , "for" , "engineer" ]);  
// Use the contains() function to check
// existence of vector elements var_dump ( $vector -> contains ( "engineer" )); var_dump ( $vector -> contains ( " engineer " , "for" )); var_dump ( $vector -> contains ( " GfG " ) );  
?>
Output:
bool (true) bool (true) bool (false)
Link: http://php.net/manual/en/ds-vector.contains.php



Get Solution for free from DataCamp guru