Ds \ Set::xor()函数是PHP中的内置函数,用于创建一个新集合,该集合包含第一组或第二组中的值,但不能同时包含两者。
用法:
Ds\Set public Ds\Set::xor ( Ds\Set $set )
参数:该函数接受单个参数$set,该参数用于保存值集。
返回值:它用于返回一个集合,该集合包含当前集合与另一个集合的异或。
以下示例程序旨在说明PHP中的Ds \ Set::xor()函数:
程序1:
<?php
// Declare a new set
$a = new \Ds\Set([1, 3, 5]);
// Declare a new set
$b = new \Ds\Set([2, 3, 6]);
// Print the xor of both set
echo("xor of both set is:\n");
print_r($a->xor($b));
?>
输出:
xor of both set is:
Ds\Set Object
(
[0] => 1
[1] => 5
[2] => 2
[3] => 6
)
程序2:
<?php
// Declare a new set
$a = new \Ds\Set([2, 3, 6, 7, 8]);
// Declare a new set
$b = new \Ds\Set([2, 3, 5, 8, 9, 10]);
// Print the xor of both set
echo("xor of both set is:\n");
var_dump($a->xor($b));
?>
输出:
xor of both set is:
object(Ds\Set)#3 (5) {
[0]=>
int(6)
[1]=>
int(7)
[2]=>
int(5)
[3]=>
int(9)
[4]=>
int(10)
}
参考: https://www.php.net/manual/en/ds-set.xor.php
相关用法
- PHP exp()用法及代码示例
- p5.js log()用法及代码示例
- p5.js cos()用法及代码示例
- p5.js sin()用法及代码示例
- d3.js d3.mean()用法及代码示例
- p5.js second()用法及代码示例
- PHP Ds\Map map()用法及代码示例
- p5.js hue()用法及代码示例
- PHP ord()用法及代码示例
- p5.js pow()用法及代码示例
- p5.js day()用法及代码示例
- d3.js d3.sum()用法及代码示例
注:本文由纯净天空筛选整理自R_Raj大神的英文原创作品 PHP | Ds\Set xor() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。