Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • PHP Tutorial
  • PHP Exercises
  • PHP Array
  • PHP String
  • PHP Calendar
  • PHP Filesystem
  • PHP Math
  • PHP Programs
  • PHP Array Programs
  • PHP String Programs
  • PHP Interview Questions
  • PHP GMP
  • PHP IntlChar
  • PHP Image Processing
  • PHP DsSet
  • PHP DsMap
  • PHP Formatter
  • Web Technology
Open In App
Next Article:
PHP | Ds\Map putAll() function
Next article icon

PHP | Ds\Map putAll() function

Last Updated : 21 Aug, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The Ds\Map::putAll() function is an inbuilt function in PHP, which is used to associates all key-value pairs of a traversable object or array. Syntax:
void public Ds\Map::putAll( mixed $pairs )
Parameter: This function accepts single parameter $pairs which is the traversal object or array. Return value: It does not return any value. Below programs illustrate the Ds\Map::putAll() function in PHP: Program 1: php
<?php   // Declare a new map $map = new \Ds\Map();  $map->putAll([     "a" => "Geeks",     "b" => "for",     "c" => "Geeks" ]);   print_r($map);  // Declare a new map $map = new \Ds\Map();  $map->putAll([     "b" => "Computer",     "e" => "Science",     "f" => "Portal" ]);   print_r($map);  ?> 
Output:
  Ds\Map Object  (      [0] => Ds\Pair Object          (              [key] => a              [value] => Geeks          )        [1] => Ds\Pair Object          (              [key] => b              [value] => for          )        [2] => Ds\Pair Object          (              [key] => c              [value] => Geeks          )    )  Ds\Map Object  (      [0] => Ds\Pair Object          (              [key] => b              [value] => Computer          )        [1] => Ds\Pair Object          (              [key] => e              [value] => Science          )        [2] => Ds\Pair Object          (              [key] => f              [value] => Portal          )    )  
Program 2: php
<?php   // Declare a new map $map = new \Ds\Map();  $map->putAll([     "Geeks1" => "computer",      "Geeks2" => "science",     "Geeks3" => 5,     "Geeks4" => 20 ]);   var_dump($map);  // Declare a new map $map = new \Ds\Map();  $map->putAll([     "x" => "A",      "y" => "B",     "z" => "C" ]);   var_dump($map);  ?> 
Output:
  object(Ds\Map)#1 (4) {    [0]=>    object(Ds\Pair)#2 (2) {      ["key"]=>      string(6) "Geeks1"      ["value"]=>      string(8) "computer"    }    [1]=>    object(Ds\Pair)#3 (2) {      ["key"]=>      string(6) "Geeks2"      ["value"]=>      string(7) "science"    }    [2]=>    object(Ds\Pair)#4 (2) {      ["key"]=>      string(6) "Geeks3"      ["value"]=>      int(5)    }    [3]=>    object(Ds\Pair)#5 (2) {      ["key"]=>      string(6) "Geeks4"      ["value"]=>      int(20)    }  }  object(Ds\Map)#5 (3) {    [0]=>    object(Ds\Pair)#1 (2) {      ["key"]=>      string(1) "x"      ["value"]=>      string(1) "A"    }    [1]=>    object(Ds\Pair)#4 (2) {      ["key"]=>      string(1) "y"      ["value"]=>      string(1) "B"    }    [2]=>    object(Ds\Pair)#3 (2) {      ["key"]=>      string(1) "z"      ["value"]=>      string(1) "C"    }  }  
Reference: https://www.php.net/manual/en/ds-map.putall.php

Next Article
PHP | Ds\Map putAll() function

R

R_Raj
Improve
Article Tags :
  • Web Technologies
  • PHP
  • PHP-function
  • PHP-ds_map

Similar Reads

    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 values() Function
    The Ds\Map::values() function is an inbuilt function in PHP which is used to return a sequence of the map's values. Syntax: Ds\Sequence public Ds\Map::values ( void ) Parameters: This function does not accepts any parameters. Return Value: It returns a Ds\Sequence containing all the values of the ma
    1 min read
    PHP | DsStack push() Function
    The Ds\Stack::push() function of PHP is used to add elements at the end of the stack. That it is used to push elements on to a stack. The elements being pushed can be of mixed data types. Syntax: void public Ds\Stack::push ($values) Parameter: This function accepts a single parameter $values which i
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences