PHP | Ds\Set intersect() Function
The Ds\Set::intersect() function is an inbuilt function in PHP which is used to create a new set which contains the intersection of two sets.
Syntax:
Ds\Set public Ds\Set::intersect ( Ds\Set $set )
Parameters: This parameter holds the set which contains set elements.
Return Value: This function returns the intersection of current set with other set.
Below programs illustrate the Ds\Set::intersect() function in PHP:
Program 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
)
Program 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)
}
Reference: https://www.php.net/manual/en/ds-set.intersect.php
Recommended Posts:
- PHP | Ds\Map intersect() Function
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- PHP | pow( ) Function
- p5.js | box() Function
- PHP | Ds\Map last() Function
- PHP | each() Function
- p5.js | nf() Function
- PHP | pos() Function
- PHP | pi( ) Function
- D3.js | d3.set.has() Function
- PHP | Ds\Map map() Function
- p5.js | cos() function
- p5.js | arc() Function
- p5.js | int() 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.



