I have some existing code I have to modify and am trying to improve some code readability and efficiency in the process. I have a various number of fields that all reference the same field in a table. The naming convention for these fields is as such: field1, field2, ... field10, where each variable has the same name with an additional numeric value appended to its end.
After these fields are populated, the code performs the exact same IF check on every field. I was wondering if there was some way I could reference this variable name dynamically, so I could instead add these IF statements to a loop. Maybe there is some way to reference a variable by using a string?
Note: I cannot use arrays for the existing fields, due to the existing data structure and SQL used to populate it.
After these fields are populated, the code performs the exact same IF check on every field. I was wondering if there was some way I could reference this variable name dynamically, so I could instead add these IF statements to a loop. Maybe there is some way to reference a variable by using a string?
Note: I cannot use arrays for the existing fields, due to the existing data structure and SQL used to populate it.
Comment