PHP | Ds\Vector first() Function Last Updated : 22 Aug, 2019 Comments Improve Suggest changes Like Article Like Report 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. Below programs illustrate the Ds\Vector::first() function in PHP: Program 1: PHP <?php // Create vector elements $vector = new \Ds\Vector([1, 2, 3, 4, 5]); echo("First element of the vector: "); // Use first() function to find // the first element var_dump($vector->first()); ?> Output: First element of the vector: int(1) Program 2: PHP <?php // Create vector elements $vector = new \Ds\Vector(["geeks", "for", "geeks"]); echo("First element of the vector: "); // Use first() function to find // the first element var_dump($vector->first()); ?> Output: First element of the vector: string(5) "geeks" Reference: http://php.net/manual/en/ds-vector.first.php Comment More infoAdvertise with us Next Article PHP | DsPair toArray() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_vector 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 | 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 | 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 | DsPair toArray() Function The Ds\Pair::toArray() function is an inbuilt function in PHP which is used to convert the Pair element into an associative array. This function does not modify the actual Pair. This method returns an array whose values without changing the order of elements. Syntax: array Ds\Pair::toArray( void ) P 1 min read PHP | DsStack toArray() Function The Ds\Stack::toArray() function of PHP is used to convert the stack to an array and returns the converted array. This function does not modify the actual Stack. Syntax: void public Ds\Stack::toArray () Parameters: This function does not accept any parameters. Return Value: This function returns the 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 Like