PHP | Ds\Vector set() Function Last Updated : 22 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 index value at which the vector value to be updated. $value: This parameter holds the value by which previous element is to be replaced. Return Value: This function does not return any value. Exception: This function throws OutOfRangeException if index is invalid. Below programs illustrate the Ds\Vector::set() function in PHP: Program 1: PHP <?php // Create new Vector $vect = new \Ds\Vector([1, 2, 3, 4, 5]); // Display the Vector elements print_r($vect); // Use set() function to set the // element in the vector $vect->set(1, 10); echo("\nVector after updating the element\n"); // Display the vector elements print_r($vect); ?> Output: Ds\Vector Object ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) Vector after updating the element Ds\Vector Object ( [0] => 1 [1] => 10 [2] => 3 [3] => 4 [4] => 5 ) Program 2: PHP <?php // Create new Vector $vect = new \Ds\Vector(["geeks", "of", "geeks"]); // Display the Vector elements print_r($vect); // Use set() function to set the // element in the vector $vect->set(1, "for"); echo("\nVector after updating the element\n"); // Display the vector elements print_r($vect); ?> Output: Ds\Vector Object ( [0] => geeks [1] => of [2] => geeks ) Vector after updating the element Ds\Vector Object ( [0] => geeks [1] => for [2] => geeks ) Reference: http://php.net/manual/en/ds-vector.set.php Comment More infoAdvertise with us Next Article PHP | Ds\Vector set() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_vector Similar Reads PHP DsSet sort() Function The Ds\Set::sort() function of DS\Set class in PHP is used to in-place sort the elements of a specified Set instance according to the values. By default, the Set is sorted according to the increasing order of the values. Syntax: void public Ds\Set::sort ([ callable $comparator ] ) Parameters: This f 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 | 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 | DsSet xor() Function The Ds\Set::xor() function is an inbuilt function in PHP which is used to create a new set which contains the value either in the first set or second set but not both. Syntax: Ds\Set public Ds\Set::xor ( Ds\Set $set ) Parameters: This function accepts a single parameter $set which is used to hold th 2 min read Like