The Ds\Set::xor() function is an inbuilt function in PHP which is used to create a new set which contains the value either in the first set or second set but not both.
Syntax:
Ds\Set public Ds\Set::xor ( Ds\Set $set )
Parameters: This function accepts a single parameter $set which is used to hold the set of values.
Return Value: It is used to return a set which contains the xor of the current set with another set.
Below programs illustrate the Ds\Set::xor() function in PHP:
Program 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
)
Program 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)
}
Reference: https://www.php.net/manual/en/ds-set.xor.php
Recommended Posts:
- PHP | Ds\Map xor() Function
- Node Jimp | Color xor
- How to calculate the XOR of array elements using JavaScript ?
- Lodash | _.xor() Method
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- PHP | Imagick floodFillPaintImage() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
- PHP | geoip_continent_code_by_name() Function
- PHP | GmagickPixel setcolor() function
- PHP | opendir() Function
- PHP | cal_to_jd() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

