PHP | Ds\Vector contains() Function
The Ds\Vector::contains() function is an inbuilt function in PHP which is used to check the vector contains given value or not.
Syntax:
bool public Ds\Vector::contains( $values )
Parameters: This function accepts a single parameter $values which contains single/many values.
Return Value: This function returns true if the given value exists, false otherwise.
Below programs illustrate the Ds\Vector::contains() function in PHP:
Program 1:
<?php // Create a vector $vector = new \Ds\Vector([1, 2, 3, 4, 5]); // Use 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:
<?php // Create a vector $vector = new \Ds\Vector(["geeks", "for", "geeks"]); // Use contains() function to check // existence of vector elements var_dump($vector->contains("geeks")); var_dump($vector->contains("geeks", "for")); var_dump($vector->contains("GfG")); ?> |
Output:
bool(true) bool(true) bool(false)
Reference: http://php.net/manual/en/ds-vector.contains.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- p5.js | box() Function
- PHP | Ds\Map get() Function
- D3.js | d3.map.set() Function
- PHP | max( ) Function
- CSS | rgb() Function
- PHP | min( ) Function
- p5.js | str() function
- p5.js | int() function
- D3.js | d3.hcl() Function
- D3.js | d3.lab() Function
- p5.js | value() Function
- PHP | dir() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



