• PHP Video Tutorials

PHP - Ds Map diff() Function



Ds\Map::diff() function can create a new map by using keys that aren't in another map.

Syntax

public Ds\Map Ds\Map::diff( Ds\Map $map )

Ds\Map:: diff() function can return the result of removing all keys from the current instance that are present in a given map.

Example 1

<?php  
   $map1 = new \Ds\Map(["1" => "10", "2" => 20, "3" => 30]);               
   $map2 = new \Ds\Map(["3" => "30", "4" => 40, "5" => 50]);
  
   echo "The difference between two maps: <br>";
   print_r($map1 -> diff($map2)); 
?>

Example 2

<?php  
   $map1 = new \Ds\Map(["1" => "Tutorials", "2" => "Point", "3" => "India"]);          
   $map2 = new \Ds\Map([ 2" => "Point", "3" => "Tutorials", "4" => "Tutorix"]); 
  
   echo "The difference between two maps: <br>"; 
   print_r($map1 -> diff($map2)); 
?>  
php_function_reference.htm
Advertisements