PHP Ds / Map putAll () Function

Syntax:
void public DsMap::putAll (mixed $pairs)
Parameter: this function takes one parameter $pair,which is a traversal object or array.Return value:returns no value. The programs below illustrate the Ds / Map::putAll()function in PHP:Program 1:  
// Declare a new map $map = new DsMap(); $map -> putAll ([ " a " = > "Geeks" , "b" = > " for " , " c " = > "Geeks"] ); print_r ( $map );  
// Declare a new map $map = new DsMap(); $map -> putAll ([ " b " = > "Computer" , "e" = > " Science " , " f " = > "Portal"] ); print_r ( $map );  
?>
Exit:
DsMap Object ( [0] = > DsPair Object ([key] = > a [value] = > Geeks) [1] = > DsPair Object ([key] = > b [value] = > for) [2 ] = > DsPair Object ([key] = > c [value] = > Geeks)) DsMap Object ([0] = > DsPair Object ([key] = > b [value] = > Computer) [1] = > DsPair Object ([key] = > e [value] = > Science) [2] = > DsPair Object ([key] = > f [value] = > Portal))
Program 2:  
// Declare a new map $map = new DsMap(); $map -> putAll ([ " Geeks1 " = > "computer" , "Geeks2" = > " science " , " Geeks3 " = > 5, " Geeks4 " = > 20 ]); var_dump ( $map );  
// Declare a new map $map = new DsMap(); $map -> putAll ([ " x " = > "A" , "y" = > " B " , " z " = > "C"] ); var_dump ( $map );  
?>
Exit:
object (DsMap ) # 1 (4) {[0] = > object (DsPair) # 2 (2) {["key"] = > string (6) "Geeks1" ["value"] = > string (8) "computer"} [1] = > object (DsPair) # 3 (2) {["key"] = > string (6) "Geeks2" ["value"] = > string (7) "science"} [2] = > object (DsPair) # 4 (2) {["key"] = > string (6) "Geeks3" ["value"] = > int (5)} [3] = > object (DsPair) # 5 (2) {["key"] = > string (6) "Geeks4" ["value"] = > int (20)}} object (DsMap) # 5 (3) {[0] = > object (DsPair) # 1 (2) {["key"] = > string (1) "x" ["value"] = > string (1) "A"} [1] = > object (DsPair) # 4 (2) {["key"] = > string (1) "y" ["value"] = > string (1) "B"} [2] = > object (DsPair) # 3 (2) {["key"] = > string (1) "z" ["value"] = > string (1) "C"}}
Link: https://www.php.net/manual/en/ds-map.putall.php



Get Solution for free from DataCamp guru