Ds \ Set::intersect()函数是PHP中的一个内置函数,用于创建包含两个集合的交集的新集合。
用法:
Ds\Set public Ds\Set::intersect ( Ds\Set $set )
参数:此参数保存包含set元素的set。
返回值:此函数返回当前设置与其他设置的交集。
以下示例程序旨在说明PHP中的Ds \ Set::intersect()函数:
程序1:
<?php
// Declare a new set
$a = new \Ds\Set([2, 3, 6]);
// Declare another new set
$b = new \Ds\Set([2, 4, 6, 7]);
// Print the Intersection of two set
echo("Intersection of both set is:\n");
print_r($a->intersect($b));
?>
输出:
Intersection of both set is:
Ds\Set Object
(
[0] => 2
[1] => 6
)
程序2:
<?php
// Declare a new set
$a = new \Ds\Set([2, 3, 6, 7, 8]);
// Declare another set
$b = new \Ds\Set([2, 3, 5, 8, 9, 10]);
// Print the Intersection of both set
echo("Intersection of both set is:\n");
var_dump($a->intersect($b));
?>
输出:
Intersection of both set is:
object(Ds\Set)#3 (3) {
[0]=>
int(2)
[1]=>
int(3)
[2]=>
int(8)
}
参考: https://www.php.net/manual/en/ds-set.intersect.php
相关用法
- PHP Ds\Map intersect()用法及代码示例
- d3.js d3.map.set()用法及代码示例
- p5.js log()用法及代码示例
- CSS var()用法及代码示例
- PHP end()用法及代码示例
- d3.js d3.max()用法及代码示例
- PHP cos( )用法及代码示例
- PHP tan( )用法及代码示例
- p5.js hex()用法及代码示例
- p5.js tan()用法及代码示例
- CSS hsl()用法及代码示例
- PHP sin( )用法及代码示例
注:本文由纯净天空筛选整理自R_Raj大神的英文原创作品 PHP | Ds\Set intersect() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
