• PHP Video Tutorials

PHP - Ds Set union() Function



Ds\Set::union() function can create a new set by using values from the current instance and another set.

Syntax

public Ds\Set Ds\Set::union( Ds\Set $set )

Ds\Set::union() function can create a new set that contains values of the current instance and values of another set.

Ds\Set::union() function can return a new set containing all values of the current instance as well as another set.

Example 1

<?php 
   $set1 = new \Ds\Set([2, 3, 5]);  
   $set2 = new \Ds\Set([2, 4, 6, 7]);  
   
   echo("The union of both set: \n");  
   print_r($set1-<union($set2)); 
?>

Example 2

<?php  
   $set1 = new \Ds\Set([2, 3, 6, 7, 8]);  
   $set2 = new \Ds\Set([2, 3, 5, 8, 9, 10]);  
  
   echo("The union of both set: \n");  
   var_dump($set1->union($set2)); 
?>
php_function_reference.htm
Advertisements