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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。