PHP | Ds\Vector push() Function Last Updated : 28 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The Ds\Vector::push() function is an inbuilt function in PHP that is used to add elements to the end of the vector. Syntax: void public Ds\Vector::push( $values ) Parameters: This function accepts a single parameter $values which contains one or more than one element to be added to the vector. Return Value: This function does not return any values. The below programs illustrate the Ds\Vector::push() function in PHP Program 1: PHP <?php // Create new vector $arr1 = new \Ds\Vector([10, 20, 30, 40, 50]); echo("Original vector elements\n"); print_r($arr1); // Use push() function to add // element to the vector $arr1->push(60); echo("\nVector after appending the elements\n"); print_r($arr1); ?> Output: Original vector elements Ds\Vector Object ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 [4] => 50 ) Vector after appending the elements Ds\Vector Object ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 [4] => 50 [5] => 60 ) Program 2: PHP <?php // Create new vector $arr1 = new \Ds\Vector([10, 20, 30, 40, 50]); echo("Original vector elements\n"); print_r($arr1); // Use push() function to add // element to the vector $arr1->push(...[60, 70]); echo("\nVector after appending the elements\n"); print_r($arr1); ?> Output: Original vector elements Ds\Vector Object ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 [4] => 50 ) Vector after appending the elements Ds\Vector Object ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 [4] => 50 [5] => 60 [6] => 70 ) Reference: http://php.net/manual/en/ds-vector.push.php Comment More infoAdvertise with us Next Article PHP | DsDeque set() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_vector Similar Reads PHP | DsStack push() Function The Ds\Stack::push() function of PHP is used to add elements at the end of the stack. That it is used to push elements on to a stack. The elements being pushed can be of mixed data types. Syntax: void public Ds\Stack::push ($values) Parameter: This function accepts a single parameter $values which i 1 min read PHP | DsDeque push() Function The Ds\Deque::push() function is an inbuilt function in PHP which is used to add the elements to the Deque by appending an element at the end of the Deque. Syntax: public Ds\Deque::push( $values ) : void Parameters: This function accepts single parameter $values which holds the elements to be added 2 min read PHP DsQueue push() Function The Ds\Queue::push() Function in PHP is used to push or insert values in a PriorityQueue instance. This function can also insert a list of values directly to the Queue. Syntax: void public Ds\Queue::push($value1, $value2, .... $valueN) Parameters: This function accepts a list of values separated by 1 min read PHP | DsVector push() Function The Ds\Vector::push() function is an inbuilt function in PHP that is used to add elements to the end of the vector. Syntax: void public Ds\Vector::push( $values ) Parameters: This function accepts a single parameter $values which contains one or more than one element to be added to the vector. Retur 2 min read PHP | DsDeque set() Function The Ds\Deque::set() function is an inbuilt function in PHP which is used to set the value at the given index in the Deque. Syntax: public Ds\Deque::set( $index, $value ) : void Parameters: This function accept two parameters as mentioned above and described below: index: This parameter holds the ind 2 min read PHP | DsVector set() Function The Ds\Vector::set() function is an inbuilt function in PHP which is used to set the value in the vector at the given index. Syntax: void public Ds\Vector::set( $index, $value ) Parameters: This function accepts two parameters as mentioned above and described below: $index: This parameter holds the 2 min read PHP | Ds\Vector push() Function min read Like