PHP | Ds\Map reverse() Function Last Updated : 22 Apr, 2022 Comments Improve Suggest changes Like Article Like Report The Ds/Map::reverse() function in PHP is used to in-place reverse the elements of a specified Map instance. That is, the function in-place reverses the order of elements present in the specified Map instance. Syntax: Ds\Map public Ds\Map::reverse ( int $position ) Parameter: This function does not accepts any parameter. Return value: The function does not returns any value. Below programs illustrate the Ds/Map::reverse() function: Program 1: PHP <?php // PHP program to illustrate reverse() function $map = new \Ds\Map([1 => 10, 2 => 20, 3 => 30]); // Reverse the Map $map->reverse(); // Print the reversed Map print_r($map); ?> Output: Ds\Map Object ( [0] => Ds\Pair Object ( [key] => 3 [value] => 30 ) [1] => Ds\Pair Object ( [key] => 2 [value] => 20 ) [2] => Ds\Pair Object ( [key] => 1 [value] => 10 ) ) Program 2: PHP <?php // PHP program to illustrate reverse() function $map = new \Ds\Map(["first" => "Geeks", "second" => "for", "third" => "Geeks"]); // Reverse the Map $map->reverse(); // Print the Map print_r($map); ?> Output: Ds\Map Object ( [0] => Ds\Pair Object ( [key] => third [value] => Geeks ) [1] => Ds\Pair Object ( [key] => second [value] => for ) [2] => Ds\Pair Object ( [key] => first [value] => Geeks ) ) Reference: http://php.net/manual/en/ds-map.reverse.php Comment More infoAdvertise with us Next Article PHP DsSet reverse() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_map Similar Reads PHP | DsMap reverse() Function The Ds/Map::reverse() function in PHP is used to in-place reverse the elements of a specified Map instance. That is, the function in-place reverses the order of elements present in the specified Map instance. Syntax: Ds\Map public Ds\Map::reverse ( int $position ) Parameter: This function does not a 2 min read PHP DsSet reverse() Function The Ds\Set::reverse() function of Ds\Set class in PHP is an inbuilt function which is used to reverse the order of elements present in the Set instance. This function reverses the Set in-place. That is, it does not uses any extra space and updates the original Set instance with reversed values. Synt 2 min read PHP DsSet reversed() Function The Ds\Set::reversed() function of Ds\Set class in PHP is an inbuilt function which is used to create a copy of the original Set with values arranged in reverse order. That is, this function returns a reversed copy of the actual set. This function does not affect the original set instance. Syntax: D 2 min read PHP | DsDeque reverse() Function The Ds\Deque::reverse() function is an inbuilt function in PHP which is used to reverse the elements in the Deque in-place. Syntax: public Ds\Deque::reverse( void ) : void Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Below programs i 2 min read PHP | DsVector reverse() Function The Ds\Vector::reverse() function is an inbuilt function in PHP which is used to reverse the vector elements in-place. Syntax: void public Ds\Vector::reverse( void ) Parameters: This function does not accepts any parameters. Return Value: This function does not return any value. Below programs illus 2 min read PHP | DsDeque reversed() Function The Ds\Deque::reversed() function is an inbuilt function in PHP which is used to return the copy of Deque which contains the elements in reversed order. Syntax: public Ds\Deque::reversed( void ) : Ds\Deque Parameters: This function does not accept any parameter. Return Value: This function returns a 2 min read Like