• PHP Video Tutorials

PHP - Ds Set toArray() Function



Ds\Set::toArray() function can convert a set to an array.

Syntax

public array Ds\Set::toArray( void )

Ds\Set::toArray() function doesn't have any parameters.

Ds\Set::toArray() function can return an array containing all values in the same order as a set.

Example 1

<?php  
   $set = new \Ds\Set([1, 2, 3, 4, 5]); 
   
   echo "The array is: \n"; 
   print_r($set->toArray()); 
?> 

Example 2

<?php  
   $set = new \Ds\Set(["Tutorials", "Point", "India"]); 
   
   echo "The array is: \n"; 
   print_r($set->toArray()); 
?> 
php_function_reference.htm
Advertisements