• PHP Video Tutorials

PHP - Ds Set slice() Function



Ds\Set::slice() function can return the sub-set of a given range.

Syntax

public Ds\Set Ds\Set::slice( int $index [, int $length ] )

Ds\Set::slice() function can create the sub-set of a given range.

Example 1

<?php  
   $set = new \Ds\Set([1, 3, 5, 7, 10, 12, 16]);  
   
   print_r($set->slice(2));  
   print_r($set->slice(1, 2));  
   print_r($set->slice(0, 3));  
?>

Example 2

<?php  
   $set = new \Ds\Set(["Tutorials", "Point", "India", "Tutorix"]);  
   
   print_r($set->slice(2));  
   print_r($set->slice(2, 0));  
   print_r($set->slice(0, 3));  
?>
php_function_reference.htm
Advertisements