• PHP Video Tutorials

PHP - Ds Sequence slice() Function


Advertisements

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

Syntax

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

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

Example 1

<?php 
   $seq = new \Ds\Vector([1, 3, 6, 9, 10, 15, 20]); 
  
   print_r($seq->slice(2)); 
   print_r($seq->slice(1, 2)); 
   print_r($seq->slice(2, -2)); 
?>

Example-2

<?php 
   $seq =  new \Ds\Vector(["Raja", "RRT", "SAT", "JTA"]); 
  
   print_r($seq->slice(3)); 
   print_r($seq->slice(2, 0)); 
   print_r($seq->slice(0, 3)); 
?>
php_function_reference.htm
Advertisements