Change language

PHP Ds / Map put () function

Syntax:
void public DsMap::put ($key, $value)
Parameter :This function takes two parameters as above and described below:
  • $key:is used to hold down a key to bind a value.
  • $value:is used to store the key value.
Return value:This function does not return any value. The following programs illustrate the Ds / Map::put()function in PHP:Program 1:  
// Declare a new map $map = new DsMap(); $map -> put ( " a " , " Geeks " ); $map -> put ( "b" , "for" ); $map -> put ( "c" , "Geeks" );  
// Show output print_r ( $map );  
// Declare a new map $map = new DsMap(); $map -> put ( " a " , " Computer " ); $map -> put ( "b" , "Science" ); $map -> put ( "c" , "Portal" );  
// Show output 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] = > a [value] = > Computer) [1] = > DsPair Object ([key] = > b [value] = > Science) [2] = > DsPair Object ([key] = > c [value] = > Portal))
Program 2:  
// Declare a new map $map = new DsMap(); $map -> put ( " Geeks1 " , " computer " ); $map -> put ( "Geeks2" , "science" ); $map -> put ( "Geeks3" , 5); $map -> put ( "Geeks3" , 20);  
// Show result var_dump ( $map );  
?>
Exit:
object (DsMap ) # 1 (3) {[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 (20)}}
Link: https://www.php.net/manual/en/ds-map.put.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