PHP end() Function: Get Last Array Element

The end() function is an array function in PHP that points the internal pointer to the last element of the array and returns its value. Its purpose is to move the internal pointer to the end of the array and return the value of the last element.

Here is an example of using the end() function:

$fruits = array('apple', 'banana', 'orange');
echo end($fruits); // 输出: orange

In this example, end($fruits) points the array pointer to the last element ‘orange’ and returns its value.

bannerAds