Ds\Map::union() 函數可以使用來自當前實例和另一個Map的值創建一個新Map。
用法
public Ds\Map Ds\Map::union( Ds\Map $map )
Ds\Map::union() 函數可以返回一個包含當前實例的所有對以及另一個映射的新映射。
例子1
<?php
$map1 = new \Ds\Map(["a" => 1, "b" => 3, "c" => 5]);
$map2 = new \Ds\Map(["a" => 2, "c" => 3, "d" => 6]);
echo("The union of both map:\n");
print_r($map1->union($map2));
?>
例子2
<?php
$map1 = new \Ds\Map(["a" => "Tutorials", "b" => "Point", "c" => "India"]);
$map2 = new \Ds\Map(["b" => "Tuotorix", "d" => "Madhapur", "e" => "Hyderabad"]);
echo("The union of both map:\n");
print_r($map1->union($map2));
?>
相關用法
- PHP Ds Map last()用法及代碼示例
- PHP Ds Map first()用法及代碼示例
- PHP Ds Map apply()用法及代碼示例
- PHP Ds Map filter()用法及代碼示例
- PHP Ds Map reduce()用法及代碼示例
- PHP Ds Map keys()用法及代碼示例
- PHP Ds Map toArray()用法及代碼示例
- PHP Ds Map put()用法及代碼示例
- PHP Ds Map diff()用法及代碼示例
- PHP Ds Map count()用法及代碼示例
- PHP Ds Map merge()用法及代碼示例
- PHP Ds Map sort()用法及代碼示例
- PHP Ds Map values()用法及代碼示例
注:本文由純淨天空篩選整理自 PHP - Ds Map union() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。