PHP | Ds\Stack copy() Function Last Updated : 18 Jan, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 original stack. Below programs illustrate the Ds\Stack::copy() function: Program 1: PHP <?php // PHP program to illustrate the // Ds\stack::copy() function // Create a Stack instance $stack = new \Ds\Stack(); // Pushing elements to Stack $stack->push("Welcome"); $stack->push("to"); $stack->push("GfG"); // Print the Copied Stack print_r($stack->copy()); ?> Output: Ds\Stack Object ( [0] => GfG [1] => to [2] => Welcome ) Program 2: PHP <?php // PHP program to illustrate the // Ds\stack::copy() function // Create a Stack instance $stack = new \Ds\Stack(); // Pushing Mixed value elements to Stack $stack->push("Welcome"); $stack->push("to"); $stack->push("GfG"); $stack->push(10); $stack->push(5.5); // Print the copied stack print_r($stack->copy()); ?> Output: Ds\Stack Object ( [0] => 5.5 [1] => 10 [2] => GfG [3] => to [4] => Welcome ) Reference: http://php.net/manual/en/ds-stack.copy.php Comment More infoAdvertise with us Next Article PHP | DsDeque copy() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_stack 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 | 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 | 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 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 | Ds\Stack copy() Function min read Like