PHP | Ds\Set intersect() Function Last Updated : 01 Feb, 2023 Comments Improve Suggest changes Like Article Like Report The Ds\Set::intersect() function is an inbuilt function in PHP which is used to create a new set which contains the intersection of two sets. Syntax: Ds\Set public Ds\Set::intersect ( Ds\Set $set ) Parameters: This parameter holds the set which contains set elements. Return Value: This function returns the intersection of current set with other set. Below programs illustrate the Ds\Set::intersect() function in PHP: Program 1: php <?php // Declare a new set $a = new \Ds\Set([2, 3, 6]); // Declare another new set $b = new \Ds\Set([2, 4, 6, 7]); // Print the Intersection of both set echo("Intersection of both set is: \n"); print_r($a->intersect($b)); ?> Output:Intersection of both set is: Ds\Set Object ( [0] => 2 [1] => 6 ) Program 2: php <?php // Declare a new set $a = new \Ds\Set([2, 3, 6, 7, 8]); // Declare another set $b = new \Ds\Set([2, 3, 5, 8, 9, 10]); // Print the Intersection of both set echo("Intersection of both set is: \n"); var_dump($a->intersect($b)); ?> Output:Intersection of both set is: object(Ds\Set)#3 (3) { [0]=> int(2) [1]=> int(3) [2]=> int(8) } Reference: https://www.php.net/manual/en/ds-set.intersect.php Comment More infoAdvertise with us Next Article PHP | DsMap intersect() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_set Similar Reads PHP | DsSet intersect() Function The Ds\Set::intersect() function is an inbuilt function in PHP which is used to create a new set which contains the intersection of two sets. Syntax: Ds\Set public Ds\Set::intersect ( Ds\Set $set ) Parameters: This parameter holds the set which contains set elements. Return Value: This function retu 1 min read PHP | DsMap intersect() Function The Ds\Map::intersect() function is an inbuilt function in PHP, which is used to create a new map which contains the intersection with another map. Syntax: public Ds\Map::intersect( Ds\Map $map ) Parameter: This function accepts single parameter $map which holds the other map which contains the key 2 min read PHP array_intersect() Function This builtin function of PHP is used to compute the intersection of two or more arrays. The function is used to compare the values of two or more arrays and returns the matches. The function prints only those elements of the first array that are present in all other arrays. Syntax: array array_inter 2 min read PHP | array_intersect_ukey() Function The array_intersect_ukey() function is an inbuilt function in PHP which is used to compute the intersection of two or more array against keys with the help of user-defined function and the function return an array. The returned array is the first array, which is matching keys and present in all para 5 min read PHP array_intersect_uassoc() Function The array_intersect_uassoc() function is an inbuilt function in PHP. It is used to compare key and values of two or more arrays by using a user-defined comparison function and return the matches.The comparison function returns an integer equal to, greater than, or less than zero. If the first argume 6 min read PHP array_intersect_assoc() Function The array_intersect_assoc() is a builtin function in PHP and is used to compute the intersection of two or more arrays. This function is similar to the function array_intersect() which is discussed in the article PHP | array_intersect() function. The function is also used to compare the values of tw 3 min read PHP array_intersect_key() Function This builtin function of PHP is used to compute the intersection of two or more arrays. The function is different from array_intersect() and array_intersect_assoc() in a way that it uses the keys for the comparison and returns the matching key elements. The function prints only those elements of the 2 min read PHP | DsDeque insert() Function The Ds\Deque::insert() function is an inbuilt function in PHP which is used to insert the value at the given index in the Deque. Syntax: public Ds\Deque::insert( $index, $values ) : void Parameters: This function accepts two parameter as mentioned above and described below: $index: This parameter ho 2 min read PHP | DsVector insert() Function The Ds\Vector::insert() function is an inbuilt function in PHP which is used to insert the element into the vector at the given index. Syntax: void public Ds\Vector::insert( $index, $values ) Parameters: This function accepts two parameter as mentioned above and described below: $index: This paramet 2 min read PHP DsSet isEmpty() Function The Ds\Set::isEmpty() function of Ds\Set class in PHP is an inbuilt function which is used to check whether a set is empty or not. If the Set instance is empty then this function returns true otherwise it returns False. Syntax: bool public Ds\Set::isEmpty ( void ) Parameters: This function does not 1 min read Like