• PHP Video Tutorials

PHP - Ds Vector get() Function



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

Syntax

public mixed Ds\Vector::get( int $index )

Ds\Vector::get() function can return a value at requested index.

Ds\Vector::get() function can throw OutOfRangeException if an index is not valid.

Example 1

<?php 
   $vector = new \Ds\Vector([1, 2, 3, 4, 5]); 

   var_dump($vector->get(2)); 
   var_dump($vector->get(1)); 
   var_dump($vector->get(4)); 
?>

Example 2

<?php 
   $vector = new \Ds\Vector(["Tutorials", "Point", "Tutorix"]); 
   
   var_dump($vector->get(0)); 
   var_dump($vector->get(1)); 
   var_dump($vector->get(2)); 
?>
php_function_reference.htm
Advertisements