PHP | Ds\Sequence reverse() Function Last Updated : 22 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Sequence::reverse() function is an inbuilt function in PHP which is used to reverse the sequence in-place. Syntax: void abstract public Ds\Sequence::reverse ( void ) Parameters: This function does not accepts any parameter. Return value: This function does not return any value. Below programs illustrate the Ds\Sequence::reverse() function in PHP: Program 1: php <?php // Create new Vector $seq = new \Ds\Vector([1, 2, 3, 4, 5]); // Display the elements print_r($seq); echo("Sequence after reversing\n"); // Use reverse() function to reverse // the element and display it $seq->reverse(); print_r($seq); ?> Output: Ds\Vector Object ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) Sequence after reversing Ds\Vector Object ( [0] => 5 [1] => 4 [2] => 3 [3] => 2 [4] => 1 ) Program 2: php <?php // Create new Vector $seq = new \Ds\Vector(["Geeks", "for", "Geeks", "Computer", "Science", "Portal"]); // Display the elements print_r($seq); echo("Sequence after reversing\n"); // Use reverse() function to reverse // the element and display it $seq->reverse(); print_r($seq); ?> Output: Ds\Vector Object ( [0] => Geeks [1] => for [2] => Geeks [3] => Computer [4] => Science [5] => Portal ) Sequence after reversing Ds\Vector Object ( [0] => Portal [1] => Science [2] => Computer [3] => Geeks [4] => for [5] => Geeks ) Reference: https://www.php.net/manual/en/ds-sequence.reverse.php Comment More infoAdvertise with us Next Article PHP | DsSequence reversed() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_sequence 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 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 | DsSet reduce() Function The Ds\Set::reduce() function is an inbuilt function in PHP which is used to reduce the set to a single value by applying operations using the callback function. Syntax: mixed public Ds\Set::reduce ( callable $callback [, mixed $initial ] ) Parameters: This function accepts two parameters as mention 2 min read PHP | DsSequence reverse() Function The Ds\Sequence::reverse() function is an inbuilt function in PHP which is used to reverse the sequence in-place. Syntax: void abstract public Ds\Sequence::reverse ( void ) Parameters: This function does not accepts any parameter. Return value: This function does not return any value. Below programs 2 min read PHP | DsSequence reversed() Function The Ds\Sequence::reversed() function is an inbuilt function in PHP which is used to return the reverse copy of sequence element. Syntax: Ds\Sequence abstract public Ds\Sequence::reversed ( void ) Parameters: This function does not accepts any parameter. Return Value: This function returns the revers 2 min read Like