PHP | Ds\Vector remove() Function
The Ds\Vector::remove() function is an inbuilt function in PHP which is used to reverse the elements of the vector in-place. For example, if the vector elements are [1, 2, 3, 4, 5], then it will be reversed as [5, 4, 3, 2, 1].
Syntax:
mixed public Ds\Vector::remove( $index )
Parameters: This function does not accept any parameter.
Return Value: This function does not return any value.
Below programs illustrate the Ds\Vector::remove() function in PHP:
Program 1:
<?php // Declare new Vector $arr = new \Ds\Vector([1, 2, 3, 4, 5, 6]); echo("Vector Elements\n"); // Desplay the Vector elements var_dump($arr); // Use reverse() function to // reverse Vector elements $arr->reverse(); echo("\nVector after reversing\n"); // Display the vector elements var_dump($arr); ?> |
Output:
Vector Elements
object(Ds\Vector)#1 (6) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
[4]=>
int(5)
[5]=>
int(6)
}
Vector after reversing
object(Ds\Vector)#1 (6) {
[0]=>
int(6)
[1]=>
int(5)
[2]=>
int(4)
[3]=>
int(3)
[4]=>
int(2)
[5]=>
int(1)
}
Program 2:
<?php // Declare new Vector $vect = new \Ds\Vector(["Learn", "data", "structures"]); echo("Vector Elements\n"); // Desplay the Vector elements print_r($vect); // Use reverse() function to // reverse Vector elements $vect->reverse(); echo("\nVector after reversing\n"); // Display the vector elements print_r($vect); ?> |
Output:
Vector Elements
Ds\Vector Object
(
[0] => Learn
[1] => data
[2] => structures
)
Vector after reversing
Ds\Vector Object
(
[0] => structures
[1] => data
[2] => Learn
)
Reference: http://php.net/manual/en/ds-vector.reverse.php
Recommended Posts:
- D3.js | d3.map.remove() Function
- PHP Ds\Set remove() Function
- p5.js | remove() Function
- D3.js | d3.set.remove() function
- PHP | Ds\Map remove() Function
- PHP | Ds\Deque remove() Function
- PHP | Ds\Vector remove() Function
- PHP | Ds\Sequence remove() Function
- How to remove style added with .css() function using JavaScript?
- How to remove error Call to undefined function curl_init()?
- Remove a cookie using PHP
- How to remove non-alphanumeric characters in PHP?
- How to remove a key and its value from an associative array in PHP ?
- Remove new lines from string in PHP
- How to remove the first character of string in PHP?
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.



