The count() function is assuming that the indexes of your array go in order; by way of the usage of stop and prev to go the array pointer, you get the genuine values. Try the use of the count() method on the array above and it will fail.

BY Best Interview Question ON 07 Apr 2020

Example

$array = array(5,6,70,10,36,2);
echo $array[count($array) -2];

// OUTPUT : 36