PHP | Ds\Pair copy() Function Last Updated : 20 Mar, 2023 Comments Improve Suggest changes Like Article Like Report 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\Pair::copy() function in PHP: Program 1: php <?php // Create new Pair $pair = new \Ds\Pair("G", "GeeksforGeeks"); // Display the pair element print_r($pair); // Use copy() function $pair->copy(); echo "Copied pair elements:\n"; // Display the pair element print_r($pair); ?> Output:Ds\Pair Object ( [key] => G [value] => GeeksforGeeks ) Copied pair elements: Ds\Pair Object ( [key] => G [value] => GeeksforGeeks ) Program 2: php <?php // Create new Pair $pair = new \Ds\Pair(["G", "GeeksforGeeks"], [1, 2]); // Display the pair element var_dump($pair); // Use copy() function $pair->copy(); echo "Copied pair elements:\n"; // Display the pair element var_dump($pair); ?> Output:object(Ds\Pair)#1 (2) { ["key"]=> array(2) { [0]=> string(1) "G" [1]=> string(13) "GeeksforGeeks" } ["value"]=> array(2) { [0]=> int(1) [1]=> int(2) } } Copied pair elements: object(Ds\Pair)#1 (2) { ["key"]=> array(2) { [0]=> string(1) "G" [1]=> string(13) "GeeksforGeeks" } ["value"]=> array(2) { [0]=> int(1) [1]=> int(2) } } Reference: https://www.php.net/manual/en/ds-pair.copy.php Comment More infoAdvertise with us Next Article PHP | hash_copy() Function jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_pair 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 | hash_copy() Function The hash_copy() function is an inbuilt function in PHP which is used to get the copy of hashing context. Syntax: hash_copy( $context ) Parameters: This function accepts single parameter $context which is used to specify the hashing context returned by hash_init() function. Return Value: This functio 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 Like