PHP | Ds\Deque copy() Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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 copy of the Deque elements. Below programs illustrate the Ds\Deque::copy() function in PHP: Program 1: PHP <?php // Declare deque $deck = new \Ds\Deque([1, 2, 3, 4, 5, 6]); echo("Elements in the Deque\n"); // Display the Deque elements var_dump($deck); // Use copy() function to // copy the Deque $deck_copy = $deck->copy(); echo("\nCopy Deque elements\n"); // Display the Deque elements var_dump($deck_copy); ?> Output: Elements in the Deque object(Ds\Deque)#1 (6) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> int(6) } Copy Deque elements object(Ds\Deque)#2 (6) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> int(6) } Program 2: PHP <?php // Declare deque $deck = new \Ds\Deque(["geeks", "for", "geeks"]); echo("Elements in the Deque\n"); // Display the Deque elements print_r($deck); // Use copy() function to // copy the Deque $deck_copy = $deck->copy(); echo("\nCopy Deque elements\n"); // Display the Deque elements print_r($deck_copy); ?> Output: Elements in the Deque Ds\Deque Object ( [0] => geeks [1] => for [2] => geeks ) Copy Deque elements Ds\Deque Object ( [0] => geeks [1] => for [2] => geeks ) Reference: https://www.php.net/manual/en/ds-deque.copy.php Create Quiz Comment B barykrg Follow 0 Improve B barykrg Follow 0 Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_map Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like