Definition
The end() function set the internal pointer of an array to its last element, and returns its value
The basic syntax of the end()
function is given with:
end(array);
The end()
function accepts the following parameters.
Parameter | Description |
---|---|
array | Required. Specifies the array to work on. |
Example1 : As we can see the below example Output the value of the current and the last element in an array
Output : Web
House
The end() function is commonly used along with the following functions:
current() – Returns the value of the current element in an array.
next() – Moves the internal pointer of an array to the next element, and returns its value.
prev() – Moves the internal pointer of an array to the previous element, and returns its value.
reset() – Set the internal pointer of an array to its first element, and returns its value.
key() – Returns the key of the current element in an array.
Example2 : In this below example that demonstrates how these functions basically work
Output :