PHP | Ds\Set first() Function
Last Updated :
21 Jan, 2021
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
$set = new \Ds\Set();
$set ->add( "Welcome" );
$set ->add( "to" );
$set ->add( "GfG" );
print_r( $set ->first());
?>
|
Program 2:
PHP
<?php
$set = new \Ds\Set();
$set ->add( "10" );
$set ->add( "20" );
$set ->add( "30" );
print_r( $set ->first());
?>
|
Reference: http://php.net/manual/en/ds-set.first.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...