How to retrieve the last element in an array using php

Using end() function we can retrieve the end index value in an array:

$endvalue= end($sample_array);

echo $endvalue;