PHP | Ds\Set diff() Function Last Updated : 22 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Set::diff() function is an inbuilt function in PHP which is used to create a set which contains the elements of the first set which are not present in the second set. Syntax: Ds\Set public Ds\Set::diff ( Ds\Set $set ) Parameters: It is used to hold the set, which value need to exclude. Return Value: It returns a new set containing the elements of the first set which are not present in the second set. Below programs illustrate the Ds\Set::diff() 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 diff of set echo("Difference of set1 and set2: \n"); print_r($a->diff($b)); ?> Output: Difference of set1 and set2: Ds\Set Object ( [0] => 3 ) Program 2: php <?php // Declare a new set $a = new \Ds\Set([2, 3, 6, 7, 8]); // Declare another new set $b = new \Ds\Set([2, 3, 5, 8, 9, 10]); // Print the diff of set echo("Difference of set1 and set2: \n"); var_dump($a->diff($b)); ?> Output: Difference of set1 and set2: object(Ds\Set)#3 (2) { [0]=> int(6) [1]=> int(7) } Reference: https://www.php.net/manual/en/ds-set.diff.php Comment More infoAdvertise with us Next Article PHP | DsMap diff() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_set Similar Reads PHP | DsSet diff() Function The Ds\Set::diff() function is an inbuilt function in PHP which is used to create a set which contains the elements of the first set which are not present in the second set. Syntax: Ds\Set public Ds\Set::diff ( Ds\Set $set ) Parameters: It is used to hold the set, which value need to exclude. Return 1 min read PHP | DsMap diff() Function The Ds\Map::diff() function is an inbuilt function in PHP which is used to create a map using the key which contains the elements of the first map which are not present in another map. Syntax: public Ds\Map::diff( $map ) Parameters: This function accepts a single parameter $map which is used to hold 2 min read PHP | DsDeque set() Function The Ds\Deque::set() function is an inbuilt function in PHP which is used to set the value at the given index in the Deque. Syntax: public Ds\Deque::set( $index, $value ) : void Parameters: This function accept two parameters as mentioned above and described below: index: This parameter holds the ind 2 min read PHP | DsVector set() Function The Ds\Vector::set() function is an inbuilt function in PHP which is used to set the value in the vector at the given index. Syntax: void public Ds\Vector::set( $index, $value ) Parameters: This function accepts two parameters as mentioned above and described below: $index: This parameter holds the 2 min read PHP DsSet sort() Function The Ds\Set::sort() function of DS\Set class in PHP is used to in-place sort the elements of a specified Set instance according to the values. By default, the Set is sorted according to the increasing order of the values. Syntax: void public Ds\Set::sort ([ callable $comparator ] ) Parameters: This f 2 min read PHP | DsMap sort() Function The Ds\Map::sort() function of DS\Map class in PHP is used to in-place sort the elements of a specified Map instance according to the values. By default, the Map is sorted according to the increasing order of the values. Syntax: Ds\Pair public Ds\Map::sort ( int $position ) Parameter: This function 2 min read Like