PHP | Ds\Sequence unshift() Function
The Ds\Sequence::unshift() function is an inbuilt function in PHP which is used to add values to the font of the sequence.
Syntax:
abstract public Ds\Sequence::unshift( $values ) : void
Parameters: This function accepts single parameter $values which contains values to add in the font of the sequence.
Return Value: This function does not return any values.
Below programs illustrate the Ds\Sequence::unshift() function in PHP:
Program 1:
<?php // Create new sequence $seq = new \Ds\Vector([12, 15, 18, 20]); // Use unshift() function to // the sequence element $seq->unshift("Geeks"); $seq->unshift("1", 1); print_r($seq); ?> |
Output:
Ds\Vector Object
(
[0] => 1
[1] => 1
[2] => Geeks
[3] => 12
[4] => 15
[5] => 18
[6] => 20
)
Program 2:
<?php // Create new sequence $seq = new \Ds\Vector(["Geeks", "for", "Geeks"]); // Use unshift() function to // the sequence element $seq->unshift(1); $seq->unshift("G", 10); var_dump($seq); ?> |
Output:
object(Ds\Vector)#1 (6) {
[0]=>
string(1) "G"
[1]=>
int(10)
[2]=>
int(1)
[3]=>
string(5) "Geeks"
[4]=>
string(3) "for"
[5]=>
string(5) "Geeks"
}
Reference: http://php.net/manual/en/ds-sequence.unshift.php
Recommended Posts:
- PHP | SplDoublyLinkedList unshift() Function
- PHP | Ds\Deque unshift() Function
- PHP | Ds\Vector unshift() Function
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- PHP | Ds\Map get() Function
- D3.js | d3.lab() Function
- PHP | each() Function
- D3.js | d3.hcl() Function
- p5.js | arc() Function
- D3.js | d3.hsl() Function
- PHP | Ds\Map put() Function
- CSS | hsl() Function
- PHP | exp() Function
- D3.js | d3.min() 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.



