PHP | Ds\Map values()函数
Ds\Map::values()函数是PHP中的一个内置函数,用于返回地图值的序列。
句法:
Ds\Sequence public Ds\Map::values ( void )
参数:此函数不接受任何参数。
返回值:它返回一个包含地图所有值的 Ds\Sequence。
下面的程序说明了PHP中的Ds\Map::values()函数:
方案一:
"Geeks", "b" => "for",
"c" => "Geeks"]);
print_r($map->values());
// Declare another new map
$map = new \Ds\Map(["b" => "Computer", "e" =>
"Science", "f" => "Portal"]);
print_r($map->values());
?>
输出:
Ds\Vector Object
(
[0] => Geeks
[1] => for
[2] => Geeks
)
Ds\Vector Object
(
[0] => Computer
[1] => Science
[2] => Portal
)
方案二:
"computer",
"Geeks2" => "science", "Geeks3" => 5, "Geeks4" => 20]);
var_dump($map->values());
// Declare another new map
$map = new \Ds\Map(["x" => "A", "y" => "B", "z" => "C"]);
var_dump($map->values());
?>
输出:
object(Ds\Vector)#2 (4) {
[0]=>
string(8) "computer"
[1]=>
string(7) "science"
[2]=>
int(5)
[3]=>
int(20)
}
object(Ds\Vector)#1 (3) {
[0]=>
string(1) "A"
[1]=>
string(1) "B"
[2]=>
string(1) "C"
}
参考: https://www. PHP.net/manual/en/ds-map.values。 PHP