+

PHP Ds / Vector push () function

Syntax:
void public DsVector::push ($values)
Parameters: This function takes one parameter $values, which contains one or more elements to add to the vector.Return value:This function does not return any values.The following programs illustrate the Ds / Vector::push()function in PHP:Program 1:  
// Create a new vector $arr1 = new DsVector ([10, 20, 30, 40, 50]); echo ( " Original vector elements " ); print_r ( $arr1 );  
// Use the push() function to add
// vector element $arr1 -> push (60); echo ( " Vector after appending the elements " ); print_r ( $arr1 );  
?>
Output:
Original vector elements DsVector Object ([0] = > 10 [1] = > 20 [2] = > 30 [3] = > 40 [4] = > 50) Vector after appending the elements DsVector Object ([0] = > 10 [1] = > 20 [2] = > 30 [3] = > 40 [4] = > 50 [5] = > 60)  Program 2:        
// Create a new vector $arr1 = new DsVector ([10, 20, 30, 40, 50]) ; echo ( " Original vector elements " ); print_r ( $arr1 );  
// Use the push() function to add
// vector element $arr1 -> push (... [60, 70]); echo ( " Vector after appending the elements " ); print_r ( $arr1 );  
?>
Output:
Original vector elements DsVector Object ([0] = > 10 [1] = > 20 [2] = > 30 [3] = > 40 [4] = > 50) Vector after appending the elements DsVector Object ([0] = > 10 [1] = > 20 [2] = > 30 [3] = > 40 [4] = > 50 [5] = > 60 [6] = > 70)
Link: http: // php. net / manual / en / ds-vector.push.php
Get Solution for free from DataCamp guru