PHP | Ds\Vector set() Function Last Updated : 22 Aug, 2019 Comments Improve Suggest changes 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 | DsSet xor() 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 PHP DsSet remove() Function The Ds\Set::remove() function of Ds\Set class in PHP is an inbuilt function which is used to remove specific values from a Set instance. This function can remove both single or multiple values from a Set. Syntax: void public Ds\Set::remove ([ mixed $...values ] ) Parameter: This function accepts the 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 PHP | DsSet sorted() Function The Ds\Set::sorted() function is an inbuilt function in PHP which is used to return a sorted copy of given set. Syntax: Ds\Set public Ds\Set::sorted ([ callable $comparator ]) Parameters: This function accepts a comparator function according to which the values will be compared while sorting the Set 2 min read PHP | DsMap remove() Function The Ds\Map::remove() function is an inbuilt function in PHP which is used to remove and return a value by key. Syntax: mixed Ds\Map::remove( $key, $default ) Parameters: This function accepts two parameters as mentioned above and described below: $key: It holds the key value which need to remove. $d 2 min read PHP | DsVector reverse() Function The Ds\Vector::reverse() function is an inbuilt function in PHP which is used to reverse the vector elements in-place. Syntax: void public Ds\Vector::reverse( void ) Parameters: This function does not accepts any parameters. Return Value: This function does not return any value. Below programs illus 2 min read Like