PHP Ds Map copy()函数用法介绍

Ds \ Map :: copy()PHP函数用于获取指定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 ))

【PHP Ds Map copy()函数用法介绍】程式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

    推荐阅读