3 ms·
It only assigns $user in a foreach when the $user is modified, or if you are trying to outsmart PHP-core and use & to pass it as a reference.
by josegonzalez 14y ago
It only assigns $user in a foreach when the $user is modified, or if you are trying to outsmart PHP-core and use & to pass it as a reference.
- encoderer 14y agoI get what you mean, but it might be helpful to translate it for everybody else: Foreach is doing an assignment in each iteration, robryan is right. But PHP variables are copy-on-write so $user is, until modified, just an entry in the symbol table which is very fast. And that for() loop also has an assignment -- the incrementer.