PHP | Ds\Sequence set() Function Last Updated : 22 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Sequence::set() function is an inbuilt function in PHP which is used to updates a value at a given index. Syntax: void abstract public Ds\Sequence::set ( int $index , mixed $value ) Parameters: This function accepts two parameters as mentioned above and described below: $index: It is used to hold the index number where value of sequence to be updated. $value: It is used to hold the new value which to be update at given index. Return value: This function does not return any value. Below programs illustrate the Ds\Sequence::set() function in PHP: Program 1: php <?php // Create new Sequence $seq = new \Ds\Vector([1, 2, 3, 4, 5]); echo("Original Sequence\n"); // Display the Sequence elements print_r($seq); // Use set() function to update // the sequence elements $seq->set(2, "Geeks"); echo("\nSequence after updating the elements\n"); // Display the Sequence elements print_r($seq); ?> Output: Original Sequence Ds\Vector Object ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) Sequence after updating the elements Ds\Vector Object ( [0] => 1 [1] => 2 [2] => Geeks [3] => 4 [4] => 5 ) Program 2: php <?php // Create new Sequence $seq = new \Ds\Vector(["Geeks", "for", "Geeks", "Computer", "Science", "Portal"]); echo("Original Sequence\n"); // Display the Sequence elements print_r($seq); // Use set() function to set // the sequence elements $seq->set(0, "Welcome"); $seq->set(1, "to"); $seq->set(2, "GeeksforGeeks"); echo("\nSequence after updating the elements\n"); // Display the Sequence elements print_r($seq); ?> Output: Original Sequence Ds\Vector Object ( [0] => Geeks [1] => for [2] => Geeks [3] => Computer [4] => Science [5] => Portal ) Sequence after updating the elements Ds\Vector Object ( [0] => Welcome [1] => to [2] => GeeksforGeeks [3] => Computer [4] => Science [5] => Portal ) Reference: https://www.php.net/manual/en/ds-sequence.set.php Comment More infoAdvertise with us Next Article PHP | Ds\Sequence set() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_sequence Similar Reads 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 DsSet reverse() Function The Ds\Set::reverse() function of Ds\Set class in PHP is an inbuilt function which is used to reverse the order of elements present in the Set instance. This function reverses the Set in-place. That is, it does not uses any extra space and updates the original Set instance with reversed values. Synt 2 min read PHP | DsMap reverse() Function The Ds/Map::reverse() function in PHP is used to in-place reverse the elements of a specified Map instance. That is, the function in-place reverses the order of elements present in the specified Map instance. Syntax: Ds\Map public Ds\Map::reverse ( int $position ) Parameter: This function does not a 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 DsSet reversed() Function The Ds\Set::reversed() function of Ds\Set class in PHP is an inbuilt function which is used to create a copy of the original Set with values arranged in reverse order. That is, this function returns a reversed copy of the actual set. This function does not affect the original set instance. Syntax: D 2 min read Like