Since PHP array are indexed from 0, the last element at any given time has the index count of array minus one. Following is a code example:
// accessing last element in an array
$a = array('adam', 'bob', 'cathy');
print $a[count($a) - 1];
The output of this code is:
cathy