PHP | Ds\Sequence push() Function Last Updated : 11 Jul, 2025 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: https://www.php.net/manual/en/ds-sequence.push.php Create Quiz Comment V vijay_raj Follow 0 Improve V vijay_raj Follow 0 Improve Article Tags : Web Technologies PHP PHP-function PHP-DS\Collection Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like