PHP | Ds\Deque last() Function Last Updated : 14 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Deque::last() function is an inbuilt function in PHP which is used to return the last element of Deque if Deque is not empty. Syntax: public Ds\Deque::last( void ) : mixed Parameters: This function does not accept any parameter. Return Value: This function returns the last element in the deque if it is not empty. Exception: This function throws UnderflowException if the Deque is empty. Below programs illustrate the Ds\Deque::last() function in PHP: Program 1: PHP <?php // Create a Deque $deck = new \Ds\Deque([1, 2, 3, 4, 5, 6]); echo("Elements in the deque\n"); // Display the Deque Elements var_dump($deck); echo("\nLast element in the deque: "); // Use last() function to display the // last element from the deque var_dump($deck->last()); ?> Output: Elements in the deque object(Ds\Deque)#1 (6) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> int(6) } Last element in the deque: int(6) Program 2: PHP <?php // Create a Deque $deck = new \Ds\Deque(["geeks", "for", "geeks"]); echo("Elements in the deque\n"); // Display the Deque Elements print_r($deck); echo("\nLast element in the deque: "); // Use last() function to display the // last element from the deque print_r($deck->last()); ?> Output: Elements in the deque Ds\Deque Object ( [0] => geeks [1] => for [2] => geeks ) Last element in the deque: geeks Reference: http://php.net/manual/en/ds-deque.last.php Comment More infoAdvertise with us Next Article PHP | DsSequence last() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_deque Similar Reads PHP | DsDeque last() Function The Ds\Deque::last() function is an inbuilt function in PHP which is used to return the last element of Deque if Deque is not empty. Syntax: public Ds\Deque::last( void ) : mixed Parameters: This function does not accept any parameter. Return Value: This function returns the last element in the dequ 2 min read PHP | DsSequence last() Function The Ds\Sequence::last() function is an inbuilt function in PHP which is used to return the last element from the sequence. Syntax: mixed abstract public Ds\Sequence::last( void ) Parameters: This function does not accept any parameters. Return value: This function returns the last element from the s 1 min read PHP | DsSet last() Function 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 ill 1 min read PHP | DsDeque get() Function The Ds\Deque::get() function is an inbuilt function in PHP which is used to return the value at the given index. Syntax: public Ds\Deque::get( $index ) : mixed Parameters: This function accepts single parameter $index which holds the index for which element is to be found. Return Value: This functio 2 min read PHP | DsDeque map() Function The Ds\Deque::map() function is an inbuilt function in PHP which is used to return the Deque with each element modified on the basis of operation performed as per the callback function. Syntax: public Ds\Deque::map( $callback ) : Ds\Deque Parameters: This function accepts single parameter $callback 2 min read PHP | DsDeque insert() Function The Ds\Deque::insert() function is an inbuilt function in PHP which is used to insert the value at the given index in the Deque. Syntax: public Ds\Deque::insert( $index, $values ) : void Parameters: This function accepts two parameter as mentioned above and described below: $index: This parameter ho 2 min read PHP | DsDeque find() Function The Ds\Deque::find() function is an inbuilt function in PHP which is used to find the index of the element in the Deque if element found in the Deque.Syntax: public Ds\Deque::find( $value ) : mixed Parameters: This function accepts single parameter $value which holds the element whose index is to be 2 min read PHP | DsDeque isEmpty() Function The Ds\Deque::isEmpty() function is an inbuilt function in PHP which is used to check the Deque is empty or not. Syntax: public Ds\Deque::isEmpty( void ) : bool Parameters: This function does not accept any parameter. Return Value: This function returns true if the Deque is empty, else return false. 1 min read PHP | DsVector last() Function The Ds\Vector::last() function is an inbuilt function in PHP which is used to return the last element of the vector. Syntax: mixed public Ds\Vector::last( void ) Parameters: This function does not contain any parameter. Return Value: This function returns the value at the last index in the vector. B 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 Like