• PHP Video Tutorials

PHP - Ds Sequence get() Function



Ds\Sequence::get() function can return the value at a given index.

Syntax

public abstract mixed Ds\Sequence::get( int $index )

Ds\Sequence::get() function can return the value at the requested index. It can throw OutOfRangeException if an index is not valid.

Example 1

<?php 
   $seq =  new \Ds\Vector(["R", "A", "J", "A", "T", "1", "2", 1, 2, 3, 4]);  
  
   var_dump($seq->get(0));  
   var_dump($seq->get(1)); 
   var_dump($seq->get(10));  
   var_dump($seq->get(5));  
   var_dump($seq->get(7));  
?>

Example 2

<?php 
   $seq =  new \Ds\Vector(["R", "A", "J", "A", "T", "1", "2", 1, 2, 3, 4]);
   $arr = array(0, 1, 4, 6, 8, 5);

   foreach($arr as $val) { 
      var_dump($seq->get($val)); 
   } 
?>
php_function_reference.htm
Advertisements