Change for loop to foreach

Wouldn't $value need to be $key instead? (which is currently not retrieved in foreach())