PHP | Ds\Set last() Function
Last Updated :
20 Jan, 2021
The Ds\Set::last() function is an inbuilt function in PHP which is used to return the last element from the Set instance.
Syntax:
void public Ds\Set::last( void )
Parameter: This function does not accept any parameter.
Return Value: This function returns the last value of the Set.
Below programs illustrate the Ds\Set::last() function in PHP:
Program 1:
PHP
<?php
$set = new \Ds\Set();
$set ->add( "Welcome" );
$set ->add( "to" );
$set ->add( "GfG" );
print_r( $set ->last());
?>
|
Program 2:
PHP
<?php
$set = new \Ds\Set();
$set ->add( "10" );
$set ->add( "20" );
$set ->add( "30" );
print_r( $set ->last());
?>
|
Reference: http://php.net/manual/en/ds-set.last.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...