PHP | Ds\Set merge() Function Last Updated : 16 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Set::merge() function is an inbuilt function in PHP which returns a set after adding all given values to the set. Syntax: Ds\Set public Ds\Set::merge ( mixed $values ) Parameters: This function accepts single parameter $values which holds the elements. Return Value: This function returns the set adding all the elements. Below programs illustrate the Ds\Set::merge() function in PHP: Program 1: php <?php // Create new set $set = new \Ds\Set([12, 15, 18, 20]); // Merge the set element and display it var_dump($set->merge([1, 2, 3])); // Display the set element var_dump($set) ?> Output: object(Ds\Set)#2 (7) { [0]=> int(12) [1]=> int(15) [2]=> int(18) [3]=> int(20) [4]=> int(1) [5]=> int(2) [6]=> int(3) } object(Ds\Set)#1 (4) { [0]=> int(12) [1]=> int(15) [2]=> int(18) [3]=> int(20) } Program 2: php <?php // Create new set $set = new \Ds\Set([12, 15, 18, 20]); // Merge the set element and display it var_dump($set->merge(["G", "E", "E", "k", "S"])); ?> Output: object(Ds\Set)#2 (8) { [0]=> int(12) [1]=> int(15) [2]=> int(18) [3]=> int(20) [4]=> string(1) "G" [5]=> string(1) "E" [6]=> string(1) "k" [7]=> string(1) "S" } Reference: https://www.php.net/manual/en/ds-set.merge.php Comment More infoAdvertise with us Next Article PHP | DsDeque merge() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_set Similar Reads PHP | DsSet merge() Function The Ds\Set::merge() function is an inbuilt function in PHP which returns a set after adding all given values to the set. Syntax: Ds\Set public Ds\Set::merge ( mixed $values ) Parameters: This function accepts single parameter $values which holds the elements. Return Value: This function returns the 1 min read PHP | DsDeque merge() Function The Ds\Deque::merge() function is an inbuilt function in PHP which is used to return the merged Deque after merging all the elements of one Deque with another by adding all the values into a copy and returns that copy. Syntax: public Ds\Deque::merge( $values ) : Ds\Deque Parameters: This function ac 2 min read PHP | DsVector merge() Function The Ds\Vector::merge() function is an inbuilt function in PHP which is used to merge all the elements to the vector. Syntax: Ds\Vector public Ds\Vector::merge( $values ) Parameters: This function accepts a single parameter $values which is the traversable object or array.Return Value: This function 2 min read PHP | DsSequence merge() Function The Ds\Sequence::merge() function is an inbuilt function in PHP which returns a sequence after adding all given values to the sequence. Syntax: abstract public Ds\Sequence::merge( $values ) : Ds\Sequence Parameter: This function accepts single parameter $values which holds the elements. Return Value 1 min read PHP array_âmerge() Function The array_merge() function is an inbuilt function in PHP that is used to merge two or more arrays into a single array. This function merges the elements or values of two or more arrays together to make a single array. The merging occurs in such a manner that the values of one array are appended at t 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 DsSet get() Function The Ds\Set::get() function of Ds\Set class in PHP is an inbuilt function which is used to get a value from the Set instance. This function is used to fetch a value present at a particular index in the Set instance. Syntax: mixed public Ds\Set::get ( int $index ) Parameters: This function accepts a s 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 array_merge_recursive() Function The array_merge_recursive() is an inbuilt function in PHP and is used to merge two or more arrays into a single array recursively. This function is used to merge the elements or values of two or more arrays together into a single array. The merging occurs in such a manner that the values of one arra 3 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 Like