Ds \ Map::xor()函数是PHP中的内置函数,用于创建一个新映射,该映射包含第一个映射或第二个映射中的值,但不能同时包含两者。
用法:
Ds\Map public Ds\Map::xor ( Ds\Map $map )
参数:此参数保存其他值映射。
返回值:它用于返回一个包含当前映射与另一个映射的异或的映射。
以下示例程序旨在说明PHP中的Ds \ Map::xor()函数:
程序1:
<?php
// Declare a new map
$a = new \Ds\Map(["a" => 1, "b" => 3, "c" => 5]);
// Declare another new map
$b = new \Ds\Map(["a" => 2, "c" => 3, "d" => 6]);
// Print the xor of two map
echo("xor of both map is:\n");
print_r($a->xor($b));
?>
输出:
xor of both map is:
Ds\Map Object
(
[0] => Ds\Pair Object
(
[key] => b
[value] => 3
)
[1] => Ds\Pair Object
(
[key] => d
[value] => 6
)
)
程序2:
<?php
// Declare a new map
$a = new \Ds\Map(["a" => "Geeks", "b" => "for",
"c" => "Geeks"]);
// Declare another new map
$b = new \Ds\Map(["b" => "Computer", "e" => "Science",
"f" => "Portal"]);
// Print the xor of two map
echo("xor of both map is:\n");
print_r($a->xor($b));
?>
输出:
xor of both map is:
Ds\Map Object
(
[0] => Ds\Pair Object
(
[key] => a
[value] => Geeks
)
[1] => Ds\Pair Object
(
[key] => c
[value] => Geeks
)
[2] => Ds\Pair Object
(
[key] => e
[value] => Science
)
[3] => Ds\Pair Object
(
[key] => f
[value] => Portal
)
)
参考: https://www.php.net/manual/en/ds-map.xor.php
相关用法
- PHP abs()用法及代码示例
- PHP end()用法及代码示例
- p5.js str()用法及代码示例
- p5.js hue()用法及代码示例
- PHP pos()用法及代码示例
- PHP cos( )用法及代码示例
- p5.js hex()用法及代码示例
- PHP sin( )用法及代码示例
- PHP key()用法及代码示例
- p5.js cos()用法及代码示例
- p5.js log()用法及代码示例
- p5.js arc()用法及代码示例
注:本文由纯净天空筛选整理自R_Raj大神的英文原创作品 PHP | Ds\Map xor() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。