PHP | Ds\Collection copy() Function Last Updated : 21 Jan, 2019 Comments Improve Suggest changes Like Article Like Report 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 programs illustrate the Ds\Collection::copy() function in PHP: Example 1: php <?php // Create a collection $collection = new \Ds\Vector([10, 15, 21, 13, 16, 18]); // Display the collection element print_r($collection); // Use copy() function to remove elements $collection->copy(); // Display the collection element print_r($collection); ?> Output: Ds\Vector Object ( [0] => 10 [1] => 15 [2] => 21 [3] => 13 [4] => 16 [5] => 18 ) Ds\Vector Object ( [0] => 10 [1] => 15 [2] => 21 [3] => 13 [4] => 16 [5] => 18 ) Example 2: php <?php // Create a collection $collection = new \Ds\Vector([10, 15, 21, 13, 16, 18]); // Display the collection element print_r($collection); // Use copy() function to remove elements $collection->copy(); // Pop an element from collection $collection->pop(); // Display the collection element print_r($collection); ?> Output: Ds\Vector Object ( [0] => 10 [1] => 15 [2] => 21 [3] => 13 [4] => 16 [5] => 18 ) Ds\Vector Object ( [0] => 10 [1] => 15 [2] => 21 [3] => 13 [4] => 16 ) Reference: http://php.net/manual/en/ds-collection.copy.php Comment More infoAdvertise with us Next Article PHP | DsSet copy() Function V vijay_raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DS\Collection Similar Reads 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 | 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 | DsCollection clear() Function The Ds\Collection::clear() function is an inbuilt function in PHP which is used to remove all values from the collection. Syntax: Ds\Collection::clear( void ) Parameters: This function does not accepts any parameters. Return Value: This function does not return any value. Below programs illustrate t 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 | DsCollection toArray() Function The Ds\Collection::toArray() function is an inbuilt function in PHP which is used to converts the collections into array. Syntax: public Ds\Collection::toArray( void ) : array Parameters: This function does not accepts any parameters. Return Value: This function returns an array containing all colle 1 min read PHP | DsCollection isEmpty() Function The Ds\Collection::isEmpty() function is an inbuilt function in PHP which is used to returns whether collection is empty. Syntax: Ds\Collection::isEmpty ( void ) : bool Parameters: This function does not accepts any parameters. Return Value: It returns True if collection is empty or False otherwise. 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 Like