PHP | Ds\Set first() Function Last Updated : 21 Jan, 2021 Comments Improve Suggest changes Like Article Like Report The Ds\Set::first() function is an inbuilt function in PHP which returns the first element of the Set. Syntax: void public Ds\Set::first( void ) Parameter: This function does not accept any parameter. Return value: This function returns the first value of the Set. Below programs illustrate the Ds\Set::first() function in PHP: Program 1: PHP <?php // PHP program to illustrate the // Ds\set::first() function // Create a set instance $set = new \Ds\Set(); // Adding elements to Set $set->add("Welcome"); $set->add("to"); $set->add("GfG"); // Print the first element from set print_r($set->first()); ?> Output: Welcome Program 2: PHP <?php // PHP program to illustrate the // Ds\set::first() function // Create a set instance $set = new \Ds\Set(); // Adding elements to Set $set->add("10"); $set->add("20"); $set->add("30"); // Print the first element from set print_r($set->first()); ?> Output: 10 Reference: http://php.net/manual/en/ds-set.first.php Comment More infoAdvertise with us Next Article PHP DsSet sort() Function gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_set Similar Reads PHP | DsSet first() Function The Ds\Set::first() function is an inbuilt function in PHP which returns the first element of the Set. Syntax: void public Ds\Set::first( void ) Parameter: This function does not accept any parameter. Return value: This function returns the first value of the Set. Below programs illustrate the Ds\Se 1 min read 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 | DsDeque first() Function The Ds\Deque::first() function is an inbuilt function in PHP which returns the first value in the Deque if Deque is not empty. Syntax: public Ds\Deque::first( void ) : mixed Parameters: This function does not accept any parameter. Return Value: This function returns the first element from the Deque, 2 min read PHP | DsSet slice() Function The Ds\Set::slice() function is an inbuilt function in PHP which is used to return the sub-set of given range. Syntax: Ds\Set public Ds\Set::slice ( int $index [, int $length ] ) Parameters: This function accepts two parameters as mentioned above and described below: $index: This parameter holds the 2 min read PHP | DsVector first() Function The Ds\Vector::first() function is an inbuilt function in PHP which is used to find the first element in the vector. Syntax: mixed public Ds\Vector::first( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the first element present in the vector. Bel 1 min read PHP DsSet sum() Function The Ds\Set::sum() function of Ds\Set class in PHP is an inbuilt function which is used to find the sum of all of the elements present in a Set. Syntax: number public Ds\Set::sum ( void ) Parameter: This function does not accepts any parameter. Return Value: This function returns the sum of the value 1 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 | 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 | DsSequence first() Function The Ds\Sequence::first() function is an inbuilt function in PHP which is used to return the first element from the sequence. Syntax: mixed abstract public Ds\Sequence::first ( void ) Parameter: This function does not accepts any parameter. Return value: This function returns the first element from t 1 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 Like