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::copy() function in PHP:
Program 1:
<?php // Create new Set $set = new \Ds\Set([10, 15, 21, 13, 16, 18]); // Display the Set element print_r($set); // Use copy() function $set->copy(); // Display the Set element print_r($set); ?> |
chevron_right
filter_none
Output:
Ds\Set Object
(
[0] => 10
[1] => 15
[2] => 21
[3] => 13
[4] => 16
[5] => 18
)
Ds\Set Object
(
[0] => 10
[1] => 15
[2] => 21
[3] => 13
[4] => 16
[5] => 18
)
Program 2:
<?php // Create new Set $set = new \Ds\Set(["Geeks", "GFG", "ABC"]); // Display the Set element print_r($set); // Use copy() function $set->copy(); // Display the Set element print_r($set); ?> |
chevron_right
filter_none
Output:
Ds\Set Object
(
[0] => Geeks
[1] => GFG
[2] => ABC
)
Ds\Set Object
(
[0] => Geeks
[1] => GFG
[2] => ABC
)
Reference: http://php.net/manual/en/ds-set.copy.php
Recommended Posts:
- PHP | copy( ) Function
- PHP | Ds\Collection copy() Function
- PHP | Ds\Vector copy() Function
- PHP Ds\Map copy() Function
- PHP | Ds\Deque copy() Function
- PHP | Ds\Stack copy() Function
- PHP Ds\PriorityQueue copy() Function
- PHP Ds\Queue copy() Function
- PHP | Ds\Pair copy() Function
- Copy the entire contents of a directory to another directory in PHP
- How to create a copy of an object in PHP?
- How to copy a file from one directory to another using PHP ?
- How to copy a DateTime object in PHP ?
- D3.js pow.copy() Function
- D3.js threshold.copy() Function
- D3.js point.copy() Function
- D3.js time.copy() Function
- D3.js band.copy() Function
- D3.js quantile.copy() Function
- D3.js log.copy() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

