PHP | Ds\Vector copy() Function Last Updated : 22 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Vector::copy() function is an inbuilt function in PHP which is used to create a copy of given vector. Syntax: Ds\Vector public Ds\Vector::copy( void ) Parameters: This function does not accept any parameter. Return Value: This function returns a shallow copy of the vector. Below programs illustrate the Ds\Vector::copy() function in PHP: Program 1: PHP <?php // Create a vector array $arr1 = new \Ds\Vector([1, 2, 3, 5]); // Use copy() function to copy // the vector array $arr2 = $arr1->copy(); echo("Original Array \n"); // Display the original array print_r($arr1); echo("Copied Array \n"); // Display the copied array print_r($arr2); ?> Output: Original Array Ds\Vector Object ( [0] => 1 [1] => 2 [2] => 3 [3] => 5 ) Copied Array Ds\Vector Object ( [0] => 1 [1] => 2 [2] => 3 [3] => 5 ) Program 2: PHP <?php // Create a vector array $arr1 = new \Ds\Vector(["geeks", "for", "geeks"]); // Use copy() function to copy // the vector array $arr2 = $arr1->copy(); echo("Original Array\n"); // Display the original array print_r($arr1); echo("Copied Array\n"); // Display the copied array print_r($arr2); ?> Output: Original Array Ds\Vector Object ( [0] => geeks [1] => for [2] => geeks ) Copied Array Ds\Vector Object ( [0] => geeks [1] => for [2] => geeks ) Reference: http://php.net/manual/en/ds-vector.copy.php Comment More infoAdvertise with us Next Article PHP | DsSet xor() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_vector Similar Reads PHP | DsSet copy() Function The Ds\Set::copy() function is an inbuilt function in PHP which is used to returns the copy of the set element. Syntax: Ds\Set public Ds\Set::copy( void ) Parameter: This function does not contains any parameter. Return value: It returns the copy of set elements. Below programs illustrate the Ds\Set 1 min read PHP | DsPair copy() Function The Ds\Pair::copy() function is an inbuilt function in PHP which is used to return a copy of Pair elements. Syntax: Ds\Pair::copy( void ) Parameters: This function does not accept any parameters. Return Value: This function returns a shallow copy of the pair element. Below programs illustrate the Ds 1 min read PHP | DsDeque copy() Function The Ds\Deque::copy() function is an inbuilt function in PHP which is used to return a copy of the Deque. This will return a shallow copy of the Deque. Syntax: public Ds\Deque::copy ( void ) : Ds\Deque Parameters: This function does not contain any parameter. Return Value: This function returns a cop 2 min read PHP | DsStack copy() Function The Ds\Stack::copy() function of PHP Ds\Stack class is used to create a shallow copy of the original stack and returns the copied stack. Syntax: Ds\Stack public Ds\Stack::copy ( void ) Parameters: This function does not accept any parameters.Return Value: This function returns a shallow copy of the 1 min read PHP DsQueue copy() Function The Ds\Queue::copy() Function in PHP is used to create a shallow copy of a particular Queue instance. This function does not affect the existing Queue instance, it just creates a shallow copy of the Queue and returns it. Syntax: Ds\Queue public Ds\Queue::copy ( void ) Parameters: This function does 1 min read PHP | DsVector copy() Function The Ds\Vector::copy() function is an inbuilt function in PHP which is used to create a copy of given vector. Syntax: Ds\Vector public Ds\Vector::copy( void ) Parameters: This function does not accept any parameter. Return Value: This function returns a shallow copy of the vector. Below programs illu 2 min read PHP | DsSet xor() Function The Ds\Set::xor() function is an inbuilt function in PHP which is used to create a new set which contains the value either in the first set or second set but not both. Syntax: Ds\Set public Ds\Set::xor ( Ds\Set $set ) Parameters: This function accepts a single parameter $set which is used to hold th 2 min read PHP | DsDeque set() Function The Ds\Deque::set() function is an inbuilt function in PHP which is used to set the value at the given index in the Deque. Syntax: public Ds\Deque::set( $index, $value ) : void Parameters: This function accept two parameters as mentioned above and described below: index: This parameter holds the ind 2 min read PHP | DsCollection copy() Function The Ds\Collection::copy() function is an inbuilt function in PHP which is used to returns the copy of collection element. Syntax: Ds\Collection::copy ( void ) : Ds\Collection Parameters: This function does not accept any parameter. Return Value: It returns the copy of collection element. Below progr 2 min read PHP | DsVector set() Function The Ds\Vector::set() function is an inbuilt function in PHP which is used to set the value in the vector at the given index. Syntax: void public Ds\Vector::set( $index, $value ) Parameters: This function accepts two parameters as mentioned above and described below: $index: This parameter holds the 2 min read Like