PHP | Ds\Vector merge() Function Last Updated : 30 Jun, 2021 Comments Improve Suggest changes Like Article Like Report The Ds\Vector::merge() function is an inbuilt function in PHP which is used to merge all the elements to the vector. Syntax: Ds\Vector public Ds\Vector::merge( $values ) Parameters: This function accepts a single parameter $values which is the traversable object or array.Return Value: This function returns the copy of the vector after merging the elements to the vector. Below programs illustrate the Ds\Vector::merge() function in PHP: Program 1: PHP <?php // Create new vector $arr1 = new \Ds\Vector([10, 20, 30, 40, 50]); echo("Original vector elements\n"); print_r($arr1); // Create new vector $arr2 = new \Ds\Vector([60, 70, 80, 90, 100]); echo("Vector Elements after merging\n"); // Use merge() function to merge two vector // and display its resultant vector print_r($arr1->merge($arr2)); ?> Output: Original vector elements Ds\Vector Object ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 [4] => 50 ) Vector Elements after merging Ds\Vector Object ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 [4] => 50 [5] => 60 [6] => 70 [7] => 80 [8] => 90 [9] => 100 ) Program 2: PHP <?php // Create new vector $arr1 = new \Ds\Vector(["geeks", "for", "geeks"]); echo("Original vector elements\n"); print_r($arr1); // Create new vector $arr2 = new \Ds\Vector([60, 70, 100]); echo("Vector Elements after merging\n"); // Use merge() function to merge two vector // and display its resultant vector print_r($arr1->merge($arr2)); ?> Output: Original vector elements Ds\Vector Object ( [0] => geeks [1] => for [2] => geeks ) Vector Elements after merging Ds\Vector Object ( [0] => geeks [1] => for [2] => geeks [3] => 60 [4] => 70 [5] => 100 ) Reference: http://php.net/manual/en/ds-vector.merge.php Comment More infoAdvertise with us Next Article PHP | DsSequence merge() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_vector Similar Reads PHP | DsSet merge() Function The Ds\Set::merge() function is an inbuilt function in PHP which returns a set after adding all given values to the set. Syntax: Ds\Set public Ds\Set::merge ( mixed $values ) Parameters: This function accepts single parameter $values which holds the elements. Return Value: This function returns the 1 min read PHP | DsDeque merge() Function The Ds\Deque::merge() function is an inbuilt function in PHP which is used to return the merged Deque after merging all the elements of one Deque with another by adding all the values into a copy and returns that copy. Syntax: public Ds\Deque::merge( $values ) : Ds\Deque Parameters: This function ac 2 min read PHP | DsVector merge() Function The Ds\Vector::merge() function is an inbuilt function in PHP which is used to merge all the elements to the vector. Syntax: Ds\Vector public Ds\Vector::merge( $values ) Parameters: This function accepts a single parameter $values which is the traversable object or array.Return Value: This function 2 min read PHP | DsSequence 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 1 min read PHP array_merge_recursive() Function The array_merge_recursive() is an inbuilt function in PHP and is used to merge two or more arrays into a single array recursively. This function is used to merge the elements or values of two or more arrays together into a single array. The merging occurs in such a manner that the values of one arra 3 min read PHP array_âmerge() Function The array_merge() function is an inbuilt function in PHP that is used to merge two or more arrays into a single array. This function merges the elements or values of two or more arrays together to make a single array. The merging occurs in such a manner that the values of one array are appended at t 2 min read Like