# PHP | Ds\Collection copy() Function

• Last Updated : 21 Jan, 2019

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:

 ```copy``();`` ` `// Display the collection element``print_r(``\$collection``);`` ` `?>`

Output:

```Ds\Vector Object (
 => 10
 => 15
 => 21
 => 13
 => 16
 => 18
)
Ds\Vector Object (
 => 10
 => 15
 => 21
 => 13
 => 16
 => 18
) ```

Example 2:

 ```copy``();`` ` `// Pop an element from collection``\$collection``->pop();`` ` `// Display the collection element``print_r(``\$collection``);`` ` `?>`

Output:

```Ds\Vector Object (
 => 10
 => 15
 => 21
 => 13
 => 16
 => 18
)
Ds\Vector Object (
 => 10
 => 15
 => 21
 => 13
 => 16
) ```

My Personal Notes arrow_drop_up
{"ft_lang_label":"__label__en","ft_lang_prob":0.5200613,"math_prob":0.7851328,"size":1431,"snap":"2022-05-2022-21","text_gpt3_token_len":451,"char_repetition_ratio":0.2284513,"word_repetition_ratio":0.66390043,"special_character_ratio":0.4081062,"punctuation_ratio":0.17760618,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96156496,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-19T06:56:32Z\",\"WARC-Record-ID\":\"<urn:uuid:543110f2-a870-4a7f-9ee4-e4784a9a03ab>\",\"Content-Length\":\"126105\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4ce4ce0f-7fd9-4561-8852-98dadd076528>\",\"WARC-Concurrent-To\":\"<urn:uuid:53923ea4-761d-4d7d-a89c-7ce97f8112be>\",\"WARC-IP-Address\":\"23.49.5.207\",\"WARC-Target-URI\":\"https://www.geeksforgeeks.org/php-dscollection-copy-function/?ref=rp\",\"WARC-Payload-Digest\":\"sha1:IIYHAU5GCCC2ZHNGDWLXHF5EDNQO6ZQ7\",\"WARC-Block-Digest\":\"sha1:DE2QN5FVQS6ZSRU4GMZHGN4V44ZNQK6Q\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662525507.54_warc_CC-MAIN-20220519042059-20220519072059-00488.warc.gz\"}"}