PHP | Ds\Map union() Function Last Updated : 29 Apr, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The Ds\Map::union() function is an inbuilt function in PHP which is used to create a new map which contains the union of two maps. Syntax: Ds\Map Ds\Map::union( $map ) Parameters: This function accepts single parameter $map which is used to hold the other map of the instance to combine with the current instance. Return Value: It returns a map which contains the union of two maps. Below programs illustrate the Ds\Map::union() function in PHP: Program 1: php <?php // Declare a new map $a = new \Ds\Map(["a" => 1, "b" => 3, "c" => 5]); // Declare another new map $b = new \Ds\Map(["a" => 2, "c" => 3, "d" => 6]); // Print the Union of two map echo("Union of both map is: \n"); print_r($a->union($b)); ?> Output: Union of both map is: Ds\Map Object ( [0] => Ds\Pair Object ( [key] => a [value] => 2 ) [1] => Ds\Pair Object ( [key] => b [value] => 3 ) [2] => Ds\Pair Object ( [key] => c [value] => 3 ) [3] => Ds\Pair Object ( [key] => d [value] => 6 ) ) Program 2: php <?php // Declare a new map $a = new \Ds\Map(["a" => "Geeks", "b" => "for", "c" => "Geeks"]); // Declare another new map $b = new \Ds\Map(["b" => "Computer", "e" => "Science", "f" => "Portal"]); // Print the union of two map echo("Union of both map is: \n"); print_r($a->union($b)); ?> Output: Union of both map is: Ds\Map Object ( [0] => Ds\Pair Object ( [key] => a [value] => Geeks ) [1] => Ds\Pair Object ( [key] => b [value] => Computer ) [2] => Ds\Pair Object ( [key] => c [value] => Geeks ) [3] => Ds\Pair Object ( [key] => e [value] => Science ) [4] => Ds\Pair Object ( [key] => f [value] => Portal ) ) Reference: https://www.php.net/manual/en/ds-map.union.php Comment More infoAdvertise with us Next Article PHP | DsSet union() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_map Similar Reads PHP | DsMap union() Function The Ds\Map::union() function is an inbuilt function in PHP which is used to create a new map which contains the union of two maps. Syntax: Ds\Map Ds\Map::union( $map ) Parameters: This function accepts single parameter $map which is used to hold the other map of the instance to combine with the curr 2 min read PHP | DsSet union() Function The Ds\Set::union() function is an inbuilt function in PHP which is used to create a new set which contains the union of two sets. Syntax: Ds\Set public Ds\Set::union ( Ds\Set $set ) Parameters: This function accepts a single parameter $set which holds the other set of the instance to combine with t 2 min read PHP | DsDeque map() Function The Ds\Deque::map() function is an inbuilt function in PHP which is used to return the Deque with each element modified on the basis of operation performed as per the callback function. Syntax: public Ds\Deque::map( $callback ) : Ds\Deque Parameters: This function accepts single parameter $callback 2 min read PHP | DsVector map() Function The Ds\Vector::map() function is an inbuilt function in PHP which is used to return the result of a callback after applying to each value in the vector. Syntax: Ds\Vector public Ds\Vector::map( $callback ) Parameters: This function accepts single parameter $callback which is to be applied to each ve 2 min read PHP | DsSequence map() Function The Ds\Sequence::map() function is an inbuilt function in PHP which returns the result after applying callback function to each value. Syntax: Ds\Sequence abstract public Ds\Sequence::map( $callback ) Parameter: This function accepts single parameter $callback. The callback apply on each value of se 1 min read PHP | DsMap xor() Function The Ds\Map::xor() function is an inbuilt function in PHP which is used to create a new map which contains the value either in the first map or second map but not both. Syntax: Ds\Map public Ds\Map::xor ( Ds\Map $map ) Parameter: This parameter holds the other map of values. Return value: It is used 2 min read Like