.. _structures-foreachneedreferencedsource: .. _foreach-needs-reference-array: Foreach Needs Reference Array +++++++++++++++++++++++++++++ When using foreach with a reference as value, the source must be a referenced array, which is a variable (or array or property or `static `_ property). When the array is the `result `_ of an expression, the array is not kept in memory after the foreach loop, and any change made with & are lost. This will do nothing This will have an actual effect .. code-block:: php Connex PHP features ------------------- + `foreach `_ + `reference `_ Suggestions ___________ * Use a referenced array when applying modifications inside a foreach loop Specs _____ +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Short name | Structures/ForeachNeedReferencedSource | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Changed Behavior ` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.8.4 | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+-------------------------------------------------------------------------------------------------------------------------+