PHP | Ds\Set contains() Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 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 Create Quiz Comment J jit_t Follow 0 Improve J jit_t Follow 0 Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_set Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like