PHP | Ds\Map map() Function Last Updated : 21 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Map::map() function of the Map class in PHP is used to apply a callback function to a Map object. This returns the result of applying the callback function to each value present on the map. The function does not update the values in the original map, instead, it just returns the result of the updates without affecting the original values. Syntax: Ds\Map public Ds\Map::map ( callable $callback ) Parameter: It accepts a callback function as a parameter. This callback function applies a specific operation on each value of the map. Return value: This function returns the result of applying the callback function on each value of the map without affecting the original values. Below program illustrate the Ds\Map::map() function in PHP: Program: php <?php // PHP program to illustrate the map() // function of Ds\map // Creating a Map $map = new \Ds\Map(["1" => "Geeks", "2" => "for", "3" => "Geeks"]); // Print the result of map() function print_r($map->map(function($key, $value){ return strtoupper($value); })); // Print the actual map print_r($map); ?> Output: Ds\Map Object ( [0] => Ds\Pair Object ( [key] => 1 [value] => GEEKS ) [1] => Ds\Pair Object ( [key] => 2 [value] => FOR ) [2] => Ds\Pair Object ( [key] => 3 [value] => GEEKS ) ) Ds\Map Object ( [0] => Ds\Pair Object ( [key] => 1 [value] => Geeks ) [1] => Ds\Pair Object ( [key] => 2 [value] => for ) [2] => Ds\Pair Object ( [key] => 3 [value] => Geeks ) ) Reference: http://php.net/manual/en/ds-map.map.php Comment More infoAdvertise with us Next Article PHP | Ds\Map map() Function G gopaldave Follow 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 | array_map() Function The array_map() is an inbuilt function in PHP and it helps to modify all elements one or more arrays according to some user-defined condition in an easy manner. It basically, sends each of the elements of an array to a user-defined function and returns an array with new values as modified by that fu 2 min read PHP | DsDeque pop() Function The Ds\Deque::pop() function is an inbuilt function in PHP which is used to remove the last element from Deque (if Deque is not empty) and return it. If Deque is empty then it throws an exception. Syntax: public Ds\Deque::pop( void ) : mixed Parameters: This function does not accept any parameter. R 2 min read Like