PHP | Ds\Sequence 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 illustrate the Ds\Sequence::reverse() function in PHP:
Program 1:
<?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); ?> |
chevron_right
filter_none
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 // 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); ?> |
chevron_right
filter_none
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
Recommended Posts:
- PHP Ds\Set reverse() Function
- PHP | Ds\Map reverse() Function
- p5.js | reverse() function
- PHP | Ds\Vector reverse() Function
- PHP | Ds\Deque reverse() Function
- PHP | Reverse a String
- Reverse a String in JavaScript
- JavaScript | Reverse a string in place.
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- PHP | Ds\Set xor() Function
- PHP | sin( ) Function
- PHP | cos( ) Function
- PHP | dir() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



