PHP end() Function (original) (raw)
Last Updated : 16 Sep, 2024
The **end() function is an inbuilt function in PHP and is used to find the last element of the given array.
The end() function changes the internal pointer of an array to point to the last element and returns the value of the last element.
**Syntax:
end($array)
**Parameters:
This function accepts a single parameter _$array. It is the array of which the last element we want to find.
**Return Value:
It returns the value of the last element of the array on success, otherwise returns FALSE on failure when the array is empty.
**Example:
**Input: array('Ram', 'Shita', 'Geeta')
**Output: Geeta
**Explanation: Here, the input array contain many elements
but output is Geeta i.e, last element of the array
as the end() function returns the last element of an array.
**Example 1: The below example illustrate the end() function in PHP.
PHP `
`
**Example 2: This example illustrates retrieving the last element from an array.
PHP `
`
PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.