Is the ‘copy’ of an array for a foreach (of php5, in this case) an immediate copy with actual overhead, or merely a lazy copy (copy on write) which only produces overhead if it detects a write manipulation?
The alternative, note in several places, is to run foreach over keys($array) — how can that really be faster?
OK, so I went off and measured it —
Looks like foreach ($a as $v) is much better than array_keys and that using &v is in the middle.