PHP | Ds\Set 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 accepts 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 program to illustarte the // 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()); ?> |
chevron_right
filter_none
Output:
Welcome
Program 2:
<?php // PHP program to illustarte the // 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()); ?> |
chevron_right
filter_none
Output:
10
Reference: http://php.net/manual/en/ds-set.first.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- PHP | next() Function
- PHP | Ds\Set xor() Function
- D3.js | d3.hsl() Function
- PHP | each() Function
- p5.js | cos() function
- PHP | pos() Function
- PHP | key() Function
- p5.js | box() Function
- D3.js | d3.max() function
- p5.js | log() function
- PHP | min( ) Function
- p5.js | tan() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



