Ds\Map::intersect() 函數可以通過將鍵與另一個Map相交來創建新Map。
用法
public Ds\Map Ds\Map::intersect( Ds\Map $map )
Ds\Map::intersect() 函數可以創建一個新映射,其中包含鍵存在於給定映射中的當前實例對。換句話說,返回當前實例的副本,其中刪除了其他Map上沒有的所有鍵。
Ds\Map::intersect() 函數可以返回當前實例和另一個Map的關鍵交集。
例子1
<?php
$mapOne = new \Ds\Map(["1" => "10", "2" => 20, "4" => 40]);
$mapTwo = new \Ds\Map(["2" => "20", "4" => 40, "5" => 50]);
print_r($mapOne -> intersect($mapTwo));
?>
例子2
<?php
$mapOne = new \Ds\Map(["1" => "Tutorials", "2" => "Point", "3" => "India"]);
$mapTwo = new \Ds\Map(["2" => "Point", "3" => "India", "4" => "Tutorix"]);
print_r($mapOne -> intersect($mapTwo));
?>
相關用法
- 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 union()用法及代碼示例
- 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 intersect() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。