PHP | Ds\Set contains() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 <?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')); ?> Output: bool(true) bool(true) bool(false) bool(true) bool(false) Program 2: php <?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)); ?> Output: bool(true) bool(true) bool(false) bool(false) bool(false) Reference: https://www.php.net/manual/en/ds-set.contains.php Comment More infoAdvertise with us Next Article PHP | DsDeque contains() Function J jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_set Similar Reads PHP str_contains() Function The str_contains() is a predefined function that is introduced with the release of PHP 8. The str_contains() function search for the substring in the given string within the expression. If the substring mentioned will be present in the string then it will return True otherwise it will return False. 2 min read PHP | DsSet 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 1 min read PHP | DsDeque contains() Function 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. Retur 1 min read PHP | DsVector 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 functi 1 min read PHP | DsSequence contains() Function The Ds\Sequence::contains() function is an inbuilt function in PHP which is used to check the given value exists in the sequence or not. Syntax: bool abstract public Ds\Sequence::contains ([ mixed $...values ] ) Parameter: This function accepts single or many values which need to check the value exi 1 min read PHP DsSet count() Function The Ds\Set::count() function of Ds\Set class in PHP is an inbuilt function which is used to count the number of values present in the Set. This is also referred to as the size of the Set instance. Syntax: int public Ds\Set::count() Parameters: This function does not accept any parameter. Return Valu 1 min read PHP | Ds\Set contains() Function min read Like