MIR0506
UnusedForeachValue
The value variable in a foreach loop is assigned but never used in the loop body. This is
typically a sign that the variable was accidentally omitted from the logic, or that only the key
was needed.
Example
Section titled “Example”<?php$items = ['a', 'b', 'c'];foreach ($items as $key => $value) { echo $key; // $value is never used}How to fix
Section titled “How to fix”If you only need the key, use the single-variable form of foreach:
<?phpforeach ($items as $key) { echo $key;}If you need the value, make sure to use $value in the loop body.