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 Create Quiz Comment R R_Raj Follow 0 Improve R R_Raj 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