Having the reference in the foreach, what does it mean and what the benefit?
For example:
foreach ($delivery as &$store) {
$store = ClassName::FunctionName($store);
}
unset($store);
I never really use reference when I do some coding in PHP.
If you don’t pass by reference into the foreach loop, any changes and updates won’t automatically be retained in the initial data structure after the loop has completed.
For example:
In this case, the array will still contain:
However in this example using references:
…the array will contain: