Change language

PHP Ds / Vector unshift () function

Syntax:
void public DsVector::unshift ($values)
Parameters: This function takes one parameter $values, which contains the values ​​to be added to the vector.Return value:This function does not return any value .The following programs illustrate the Ds / Vector::unshift()function in PHP:Program 1:  
// Create a new vector $vect = new DsVector ([3, 6, 1, 2, 9, 7]); echo ( " Original vector: " );  
// Show vector elements print_r ( $vect ); echo ( " Array elements after inserting new element " );  
// Use the unshift() function to link elements $vect -> unshift (10, 20, 30);  
// Show updated vector elements print_r ( $vect );  
?>
Output:
Original vector: DsVector Object ([0] = > 3 [1] = > 6 [2] = > 1 [3] = > 2 [4] = > 9 [5] = > 7) Array elements after inserting a new element DsVector Object ([0] = > 10 [1] = > 20 [2] = > 30 [3] = > 3 [4] = > 6 [5 ] = > 1 [6] = > 2 [7] = > 9 [8] = > 7)
Program 2:  
// Create a new vector $vect = new DsVector ([ " engineer " , "for" , "engineer" ]); echo ( " Original vector: " );  
// Show vector elements print_r ( $vect ); echo ( " Array elements after inserting new element " );  
// Use the unshift() function to link elements $vect -> unshift ( "PHP articles" );  
// Show updated vector elements print_r ( $vect );  
?>
Output:
Original vector: DsVector Object ([0] = > engineer [1] = > for [2] = > engineer) Array elements after inserting a new element DsVector Object ([0] = > PHP articles [1] = > engineer [2] = > for [3] = > engineer)
Link: http://php.net/manual/en/ds-vector.unshift.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method