• PHP Video Tutorials

PHP - Ds Set construct() Function



Ds\Set::__construct() function can create a new instance.

Syntax

public Ds\Set::__construct([ mixed $...values ] )

Ds\Set::__construct() function can create a new instance by using either a traversable object or an array for initial values.

Example 1

<?php 
   $set = new \Ds\Set(); 
   print_r($set); 
  
   $set = new \Ds\Set(["I", "N", "D", "I", "A"]);  
   print_r($set); 
?>

Example 2

<?php  
   $set = new \Ds\Set([1, 3, 5, 7, 9]);  
   var_dump($set); 
  
   $set = new \Ds\Set([1, 3, 5, 7, 9, 10]);  
   var_dump($set); 
?>
php_function_reference.htm
Advertisements