PHP | Ds\Sequence push() Function Last Updated : 22 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Sequence::push() function is an inbuilt function in PHP which adds values to the end of the sequence. Syntax: void abstract public Ds\Sequence::push( $values ) Parameters: This function accepts single parameter $values which contains one or more values. It hold the value to be added in the sequence. Return value: This function does not return any value. Below programs illustrate the Ds\Sequence::push() function in PHP: Program 1: php <?php // Create new sequence $seq = new \Ds\Vector([12, 15, 18, 20]); // Use push() function to add // element in the sequence $seq->push(24); // Use push() function to add // element in the sequence $seq->push("S"); // Use push() function to add // element in the sequence $seq->push("Geeks"); // Use push() function to add // element in the sequence $seq->push(2); var_dump($seq); ?> Output: object(Ds\Vector)#1 (8) { [0]=> int(12) [1]=> int(15) [2]=> int(18) [3]=> int(20) [4]=> int(24) [5]=> string(1) "S" [6]=> string(5) "Geeks" [7]=> int(2) } Program 2: php <?php // Create new sequence $seq = new \Ds\Vector([12, 15, 18, 20]); $arr = array ("g", "e", "e", "k"); // Loop run for every array element foreach ($arr as $val) { // Use push() function to add // element in the sequence $seq->push($val); } var_dump($seq); ?> Output: object(Ds\Vector)#1 (8) { [0]=> int(12) [1]=> int(15) [2]=> int(18) [3]=> int(20) [4]=> string(1) "g" [5]=> string(1) "e" [6]=> string(1) "e" [7]=> string(1) "k" } Reference: http://php.net/manual/en/ds-sequence.push.php Comment More infoAdvertise with us Next Article PHP | Ds\Sequence push() Function V vijay_raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DS\Collection 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 | DsSet reduce() Function The Ds\Set::reduce() function is an inbuilt function in PHP which is used to reduce the set to a single value by applying operations using the callback function. Syntax: mixed public Ds\Set::reduce ( callable $callback [, mixed $initial ] ) Parameters: This function accepts two parameters as mention 2 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 Like