|
|
|
|
|
by mdaniel
2038 days ago
|
|
For that code snippet specifically, you're actually better off pre-declaring the vars since the loop repeatedly calls `count($array)` but hopefully(!) its size doesn't change over time. Is there such a function in php like "enumerate" in python, that yields a tuple of (counter, item) for each item in the first argument to enumerate? That is to say: is it possible to do what you're asking with composition rather than a language change? |
|
(Since some time in PHP 7, before that count() went via function call overhead)