Well, you've chosen a strange name for your variable, which is what throws you off
echo $lastIndex;
which is most definitely not an index of $fruits. However
# This is now the last array index
$fruit['giant strawberry'] = 'yummy';
# And now this is...
$fruit['new_last_index'] = 'not a fruit';
# So this still has nothing to do with last index, but at least now there is an index
# matching the value of this variable
echo $fruit[$lastIndex];
And from the php documentation for [man]end[/man]
end() advances array's internal pointer to the last element, and returns its value.
Note that it says "value" not "key".