PHP | Ds\Deque merge() Function Last Updated : 14 Aug, 2019 Comments Improve Suggest changes Like Article Like Report 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 accepts single parameter $values which contains the values to be merged with the calling Deque. Return Value: This function returns a Deque which contains all the elements of both the Deque. Below programs illustrate the Ds\Deque::merge() function in PHP: Program 1: PHP <?php // Declare a deque $deck = new \Ds\Deque([10, 20, 30, 40, 50, 60]); echo("Elements of first deque\n"); // Display the deque Elements print_r($deck); // Declare another deque $deck2 = new \Ds\Deque([70, 80, 90, 100]); echo("\nElements of second deque\n"); print_r($deck2); echo("\nMerged deque elements\n"); // Merge the both deque print_r($deck->merge($deck2)); ?> Output: Elements of first deque Ds\Deque Object ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 [4] => 50 [5] => 60 ) Elements of second deque Ds\Deque Object ( [0] => 70 [1] => 80 [2] => 90 [3] => 100 ) Merged deque elements Ds\Deque 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 // Declare a deque $deck = new \Ds\Deque(["geeks", "for", "geeks"]); echo("Elements of first deque\n"); // Display the deque Elements print_r($deck); // Declare another deque $deck2 = new \Ds\Deque(["practicing", "data", "structures"]); echo("\nElements of second deque\n"); print_r($deck2); echo("\nMerged deque elements\n"); // Merge the both deque print_r($deck->merge($deck2)); ?> Output: Elements of first deque Ds\Deque Object ( [0] => geeks [1] => for [2] => geeks ) Elements of second deque Ds\Deque Object ( [0] => practicing [1] => data [2] => structures ) Merged deque elements Ds\Deque Object ( [0] => geeks [1] => for [2] => geeks [3] => practicing [4] => data [5] => structures ) Reference: http://php.net/manual/en/ds-deque.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_deque Similar Reads 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 | 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 | 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 get() Function The Ds\Deque::get() function is an inbuilt function in PHP which is used to return the value at the given index. Syntax: public Ds\Deque::get( $index ) : mixed Parameters: This function accepts single parameter $index which holds the index for which element is to be found. Return Value: This functio 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 | DsDeque map() Function The Ds\Deque::map() function is an inbuilt function in PHP which is used to return the Deque with each element modified on the basis of operation performed as per the callback function. Syntax: public Ds\Deque::map( $callback ) : Ds\Deque Parameters: This function accepts single parameter $callback 2 min read PHP | DsDeque insert() Function The Ds\Deque::insert() function is an inbuilt function in PHP which is used to insert the value at the given index in the Deque. Syntax: public Ds\Deque::insert( $index, $values ) : void Parameters: This function accepts two parameter as mentioned above and described below: $index: This parameter ho 2 min read PHP | DsSequence get() Function The Ds\Sequence::get() function is an inbuilt function in PHP which returns the value at given index. Syntax: mixed abstract public Ds\Sequence::get ( int $index ) Parameter: This function accepts single parameter $index which holds the index to access element. Return value: This function returns th 1 min read PHP | DsDeque find() Function The Ds\Deque::find() function is an inbuilt function in PHP which is used to find the index of the element in the Deque if element found in the Deque.Syntax: public Ds\Deque::find( $value ) : mixed Parameters: This function accepts single parameter $value which holds the element whose index is to be 2 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