PHP的Ds \ Map::copy()函数用于获取指定Map实例的浅拷贝。它会以与指定Map实例相同的顺序返回包含所有键值对的Map实例的副本。
用法:
Ds\Map public Ds\Map::copy ( )
参数:该函数不接受任何参数。
返回值:它返回指定Map实例的浅拷贝。
以下示例程序旨在说明Ds \ Map::copy()函数:
程序1:
<?php
// PHP program to illustrate copy() function
$map = new \Ds\Map([1 => "Geeks", 2 => "for",
3 => "Geeks"]);
print_r($map->copy());
?>输出:
Ds\Map Object
(
[0] => Ds\Pair Object
(
[key] => 1
[value] => Geeks
)
[1] => Ds\Pair Object
(
[key] => 2
[value] => for
)
[2] => Ds\Pair Object
(
[key] => 3
[value] => Geeks
)
)
程序2:
<?php
// PHP program to illustrate copy() function
$map = new \Ds\Map(["first" => "Geeks", "second" => "for",
"third" => "Geeks"]);
print_r($map->copy());
?>输出:
Ds\Map Object
(
[0] => Ds\Pair Object
(
[key] => first
[value] => Geeks
)
[1] => Ds\Pair Object
(
[key] => second
[value] => for
)
[2] => Ds\Pair Object
(
[key] => third
[value] => Geeks
)
)
参考:http://php.net/manual/en/ds-map.copy.php
相关用法
- PHP copy( )用法及代码示例
- PHP Ds\Set copy()用法及代码示例
- PHP Ds\Queue copy()用法及代码示例
- PHP Ds\Deque copy()用法及代码示例
- PHP Ds\PriorityQueue copy()用法及代码示例
- PHP Ds\Pair copy()用法及代码示例
- PHP Ds\Stack copy()用法及代码示例
- PHP Ds\Vector copy()用法及代码示例
- PHP Ds\Collection copy()用法及代码示例
- PHP pos()用法及代码示例
- PHP pi( )用法及代码示例
注:本文由纯净天空筛选整理自gopaldave大神的英文原创作品 PHP Ds\Map copy() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
