• PHP Video Tutorials

PHP - Ds Vector copy() Function



Ds\Vector::copy() function can return a shallow copy of vector.

Syntax

public Ds\Vector Ds\Vector::copy( void )

Ds\Vector::copy() function doesn't have any parameters. This function can return a shallow copy of the vector.

Example 1

<?php 
   $array1 = new \Ds\Vector([1, 2, 3, 5]); 
   $array2 = $arr1->copy(); 
  
   echo("The original array is: \n"); 
   print_r($array1); 
  
   echo("The copied array is: \n"); 
   print_r($array2); 
?> 

Example 2

<?php 
   $array1 = new \Ds\Vector(["Tutorials", "Point", "Tutorix"]); 
   $array2 = $array1->copy(); 
  
   echo("The original array is: \n"); 
   print_r($array1); 
  
   echo("The copied array is: \n"); 
   print_r($array2); 
?>
php_function_reference.htm
Advertisements