Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

html
css
php
communitycreator

What is the PHP | Ds\Set last() function?

Saad Akbar

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code

Ds\Set last() is an inbuilt function that returns the last value in a set.

Syntax


public void Ds\Set::last( void )

Parameters

This function takes in no parameters

Return value

This function returns the last value in the set. It can throw an exception if the set is empty.

Code

The following code finds the last element using the last() function and prints it:

<?php
$set = new \Ds\Set();
$set->add("10");
$set->add("20");
$set->add("60");
$set->add("40");
print_r($set->last());
?>

Output

40

RELATED TAGS

html
css
php
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code
Keep Exploring