While not quite as ergonomic as your example, it's rather trivial to extend ArrayIterator to accomplish your goal:
foreach ($iter = new IndexingIterator($array) as $k => $v) {
echo $iter->index();
}