PHP | Ds\Set contains() Function
The Ds\Set::contains() function is an inbuilt function in PHP which is used to check the given value exists in the set or not. This function compares the value and its type.
Syntax:
bool public Ds\Set::contains( $values )
Parameters: This function accepts a single or many values which need to check the value exist in the set or not.
Return value: If value exist in the set then it returns True otherwise returns False.
Below programs illustrate the Ds\Set::contains() function in PHP:
Program 1:
<?php // Declare new Set $set = new \Ds\Set(['G', 'e', 'e', 'k', 's', 5, 2, 7]); // Use contains() function to check elements // exist in the Set or not var_dump($set->contains('G')); var_dump($set->contains('k')); var_dump($set->contains('p')); var_dump($set->contains(7)); var_dump($set->contains('5')); ?> |
bool(true) bool(true) bool(false) bool(true) bool(false)
Program 2:
<?php // Declare new Set $set = new \Ds\Set(['G', 'e', 'e', 'k', 's', 5, 2, 7]); // Use contains() function to check elements // exist in the Set or not var_dump($set->contains('G', 'e')); var_dump($set->contains('k', 'e', 7)); var_dump($set->contains('p', '1')); var_dump($set->contains(7, 1)); var_dump($set->contains('5', 5)); ?> |
bool(true) bool(true) bool(false) bool(false) bool(false)
Reference: http://php.net/manual/en/ds-set.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 ?
- PHP | next() Function
- PHP | Ds\Set xor() Function
- D3.js | d3.hsl() Function
- PHP | each() Function
- p5.js | cos() function
- PHP | pos() Function
- PHP | key() Function
- p5.js | box() Function
- D3.js | d3.max() function
- p5.js | log() function
- PHP | min( ) Function
- p5.js | tan() 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.



