• PHP Video Tutorials

PHP - Ds Vector construct() Function



Ds\Vector::__construct() function can create a new instance.

Syntax

public Ds\Vector::__construct([ mixed $values ] )

Ds\Vector::__construct() function can create a new instance by using either a traversable object or an array for initial values.

Example 1

<?php  
   vector = new \Ds\Vector(); 
   print_r($vector); 
   
   $vector = new \Ds\Vector(["R", "A", "J", "T"]);  
   print_r($vector); 
?>

Example 2

<?php  
   $vector = new \Ds\Vector([1, 2, 3, 4, 5]);  
   var_dump($vector); 
   
   $vector = new \Ds\Vector([1, 3, 5, 8, 9, 11]);  
   var_dump($vector); 
?>
php_function_reference.htm
Advertisements