PHP | Ds\Sequence first() Function Last Updated : 21 Aug, 2019 Comments Improve Suggest changes Like Article Like Report 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 the sequence. Below programs illustrate the Ds\Sequence::first() function in PHP: Example 1: php <?php // Create new sequence $seq = new \Ds\Vector([10, 20, 13, 25]); // Display the first element from the sequence var_dump($seq->first()); // Create new sequence $seq = new \Ds\Vector(['G', 'e', 'e', 'k', 's']); // Display the first element from the sequence var_dump($seq->first()); ?> Output: int(10) string(1) "G" Example 2: php <?php // Create new sequence $seq = new \Ds\Vector([21, 23, 'p', 'x']); // Display the first element // from the sequence var_dump($seq->first()); // Function to push an element $seq->insert(0, "G"); // Display the first element // from the sequence var_dump($seq->first()); ?> Output: int(21) string(1) "G" Reference: http://php.net/manual/en/ds-sequence.first.php Comment More infoAdvertise with us V vijay_raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DS\Collection 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 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 | 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 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 | 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 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 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 | DsVector reduce() Function The Ds\Vector::reduce() function is an inbuilt function in PHP which reduce the vector to a single value by applying operations in the callback function. Syntax: mixed public Ds\Vector::reduce( $callback, $initial ) Parameters: This function accepts two parameters as mentioned above and described be 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 Like