PHP Ds\Set reversed() Function Last Updated : 16 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: Ds\Set public Ds\Set::reversed ( void ) Parameter: This function does not accepts any parameter. Return Value: This function returns a reversed copy of the actual Set instance. Below programs illustrate the Ds\Set::reversed() function: Program 1: php <?php // Declare an empty set $set = new \Ds\Set([1, 2, 3, 4, 5]); // Print the reversed copy echo("Reversed Set is: \n"); print_r($set->reversed()); // Actual Set remains unchanged echo "\n\nActual Set is:\n"; print_r($set); ?> Output: Reversed Set is: Ds\Set Object ( [0] => 5 [1] => 4 [2] => 3 [3] => 2 [4] => 1 ) Actual Set is: Ds\Set Object ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) Program 2: php <?php // Declare an empty set $set = new \Ds\Set(["Welcome", "2", "Geeks"]); // Print the reversed copy echo("Reversed Set is: \n"); print_r($set->reversed()); // Actual Set remains unchanged echo "\n\nActual Set is:\n"; print_r($set); ?> Output: Reversed Set is: Ds\Set Object ( [0] => Geeks [1] => 2 [2] => Welcome ) Actual Set is: Ds\Set Object ( [0] => Welcome [1] => 2 [2] => Geeks ) Reference: http://php.net/manual/en/ds-set.reversed.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_set Similar Reads 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 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 | 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 | 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 PHP | DsVector reversed() Function The Ds\Vector::reversed() function is an inbuilt function in PHP which is used to reverse the elements of vector after copying the elements of original vector into a copy. Syntax: public Ds\Vector::reversed( void ) : Ds\Vector Parameters: This function does not accept any parameter. Return Value: Th 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 Like