• PHP Video Tutorials

PHP - Ds Set add() Function



Ds\Set::add() function can add values to the set.

Syntax

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

Ds\Set::add() function can add all given values to the set that haven't already been added.

Ds\Set::add() function doesn't return any value.

Example 1

<?php 
   $set = new \Ds\Set(); 
   $set->add(5); 
   $set->add("TutorialsPoint"); 
   $set->add("Tutorix"); 
   $set->add(20); 
  
   var_dump($set); 
?> 

Example 2

<?php 
   $set = new \Ds\Set(); 
   $set->add(10, 20, 30, 40, "TutorialsPoint", "Tutorix", "India"); 
   print_r($set); 
?> 
php_function_reference.htm
Advertisements