PHP | Ds\Sequence merge() Function
The Ds\Sequence::merge() function is an inbuilt function in PHP which returns a sequence after adding all given values to the sequence.
Syntax:
abstract public Ds\Sequence::merge( $values ) : Ds\Sequence
Parameter: This function accepts single parameter $values which holds the elements.
Return Value: This function returns the sequence adding all the elements.
Below programs illustrate the Ds\Sequence::merge() function in PHP:
Program 1:
<?php // Create new sequence $seq = new \Ds\Vector([12, 15, 18, 20]); // Merge the sequence and display it var_dump($seq->merge([1, 2, 3])); // Display the sequence element var_dump($seq) ?> |
Output:
object(Ds\Vector)#2 (7) {
[0]=>
int(12)
[1]=>
int(15)
[2]=>
int(18)
[3]=>
int(20)
[4]=>
int(1)
[5]=>
int(2)
[6]=>
int(3)
}
object(Ds\Vector)#1 (4) {
[0]=>
int(12)
[1]=>
int(15)
[2]=>
int(18)
[3]=>
int(20)
}
Program 2:
<?php // Create new sequence $seq = new \Ds\Vector([12, 15, 18, 20]); // Merge the sequence and display it var_dump($seq->merge(["G", "E", "E", "k", "S"])); ?> |
Output:
object(Ds\Vector)#2 (9) {
[0]=>
int(12)
[1]=>
int(15)
[2]=>
int(18)
[3]=>
int(20)
[4]=>
string(1) "G"
[5]=>
string(1) "E"
[6]=>
string(1) "E"
[7]=>
string(1) "k"
[8]=>
string(1) "S"
}
Reference: http://php.net/manual/en/ds-sequence.merge.php
Recommended Posts:
- D3.js | d3.merge() function
- PHP | Ds\Map merge() Function
- PHP | Ds\Set merge() Function
- PHP | Ds\Deque merge() Function
- PHP | Ds\Vector merge() Function
- How to merge two PHP objects?
- Merge two arrays keeping original keys in PHP
- How to merge properties of two JavaScript objects dynamically?
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- D3.js | d3.map.get() Function
- D3.js | d3.map.has() Function
- PHP Ds\Map sum() Function
- p5.js | box() Function
- PHP | pi( ) 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.



