Ds\Map::intersect() function can create a new map by intersecting keys with another map.
public Ds\Map Ds\Map::intersect( Ds\Map $map )
Ds\Map::intersect() function can create a new map containing the pairs of current instance whose keys are present in a given map. In other words, returning a copy of the current instance with all keys removed that are not on the other map.
Ds\Map::intersect() function can return a key intersection of the current instance and another map.
<?php $mapOne = new \Ds\Map(["1" => "10", "2" => 20, "4" => 40]); $mapTwo = new \Ds\Map(["2" => "20", "4" => 40, "5" => 50]); print_r($mapOne -> intersect($mapTwo)); ?>
<?php $mapOne = new \Ds\Map(["1" => "Tutorials", "2" => "Point", "3" => "India"]); $mapTwo = new \Ds\Map(["2" => "Point", "3" => "India", "4" => "Tutorix"]); print_r($mapOne -> intersect($mapTwo)); ?>