What is the difference between these?
Throughout stuff that touches on the cart, you see things like:
What is the difference between these?
Throughout stuff that touches on the cart, you see things like:
If you wanted to do that on $v, you would need to change the foreach() statement to read:
foreach ($cart_products as $k => &$v) {
which would then make $v be a pointer into (by reference) $cart_products[$k] rather than a copy of $cart_products[$k] (by value).
Right I can see how that's an alternate way of working with what's there, but my real question is more around the notion of why is there $cart_products, when $cart already has $cart['products'].
So for example in that block of code I pasted, they iterate on $cart_products yet they use $cart['products'] (which is similar enough to share the same key) in the function call.
You're correct in that it's less clear even though it references the same data.
I'm guessing it's a coding error but in this instance does not have any negative side effects since $k is the operative value.