Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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();
    }


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: