How can I get the current element number when I\'m traversing a array?
I know about count(), but I was hoping there\'s a built-in function for getting the current field
There is no way to get a position which you really want. For associative array, to determine last iteration you can use already mentioned counter variable, or determine last item's key first:
end($array); $last = key($array); foreach($array as $key => value) if($key == $last) ....