• PHP Video Tutorials

PHP - Ds Vector last() Function



Ds\Vector::last() function can return a last value.

Syntax

public mixed Ds\Vector::last( void )

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

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

Example 1

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

Example 2

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