Change language

PHP Ds / Map union () function

Syntax:
DsMap DsMap::union ($map) 
Parameters:This function takes one parameter $map,which is used to store another instance map to merge with the current instance.Return value:returns a map that contains the concatenation of two maps. The following programs illustrate the Ds / Map::union() function in PHP:Program 1:  
// Declare a new map $a = new DsMap ([ "a" = > 1, "b" = > 3, "c"
= > five]);  
// Declare another new map $b = new DsMap ([ " a " = > 2, " c " = > 3, " d " = > 6 ]);  
// Print a map of the union of the two echo ( "Union of both map is:" ); print_r ( $a -> union ( $b )) ;  
?>
Exit:
Union of both map is: DsMap Object ([0] = > DsPair Object ([key] = > a [value] = > 2) [1] = > DsPair Object ([key] = > b [value] = > 3) [2] = > DsPair Object ([key] = > c [value] = > 3) [3] = > DsPair Object ([key] = > d [value] = > 6)) 
Program 2:  
// Declare a new map $a = new DsMap ([ "a" = > "Geeks" , " b " = > " for " , "c" = > "Geeks" ]);  
// Declare another new map $b = new DsMap ([ " b " = > " Computer " , "e" = > "Science" , "f" = > "Portal" ]);  
// Print the merge of the two cards echo ( "Union of both map is:" ); print_r ( $a -> union ( $b )) ;  
?>
Exit:
Union of both map is: DsMap Object ([0] = > DsPair Object ([key] = > a [value] = > Geeks) [1] = > DsPair Object ([key] = > b [value] = > Computer) [2] = > DsPair Object ([key] = > c [value] = > Geeks) [3] = > DsPair Object ([key] = > e [value] = > Science) [4] = > DsPair Object ([key] = > f [value] = > Portal)) 
Link:https://www.php.net/manual/en/ds-map.union.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method