• PHP Video Tutorials

PHP - Ds Vector first() Function



Ds\Vector::first() function can return the first value in a vector.

Syntax

public mixed Ds\Vector::first( void )

Ds\Vector::first() function doesn't have any parameters. This function can return the first value in a vector.

Ds\Vector::first() function can throw UnderflowException if empty.

Example 1

<?php
   $vector = new \Ds\Vector([1, 2, 3, 4, 5]); 
   
   echo("The first element of vector:"); 
   var_dump($vector->first()); 
?>

Example 2

<?php 
   $vector = new \Ds\Vector(["Tutorials", "Point", "Tutorix"]); 
  
   echo("The first element of vector:"); 
   var_dump($vector->first()); 
?>
php_function_reference.htm
Advertisements