The docs do not specify this, but adding to the array using the brackets syntax:
$my_array[] = $new_value;
will not advance the internal pointer of the array. therefore, you cannot use current() to get the last value added or key() to get the key of the most recently added element.
You should do an end($my_array) to advance the internal pointer to the end ( as stated in one of the notes on end() ), then
$last_key = key($my_array); // will return the key
$last_value = current($my_array); // will return the value
If you have no need in the key, $last_value = end($my_array) will also do the job.
- Sergey.