Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
kingdomcome50
on Nov 27, 2020
|
parent
|
context
|
favorite
| on:
PHP 8
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: