The code you use if a lie. Even literally it might look like the same code, however the variables are not (http://3v4l.org/jainJ).
To answer your actual question, for consistent results use the right tools.
If you need a variable with an array value, assign it:
$list = array(....);
If you need to get the current value of that array, use it before the foreach
:
$current = current($list);
Because inside the foreach
this might be the same variable name but the value will be different (imagine, you're iterating!).
If you need the current value per each iteration, use it:
foreach ($list as $current) {
...
}
See $current
?
Oh gosh, yeah, it was that easy. Wait I already have consistent results. Oh and it was that easy to not fool myself. Yay! ;)
For the log: Passing a variable as function parameter makes it a new variable. Even when a reference (that is explained).
When in doubt, do not use PHP references. Or not even variables: http://3v4l.org/6p5nZ