3 ms·
While not quite as ergonomic as your example, it's rather trivial to extend ArrayIterator to accomplish your goal: foreach ($iter = new IndexingIterator($a
by kingdomcome50 6y ago
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();
}