Count through variables

Count through variables

I have a form with fields named like this:

Field1
Field2
Field3
...
...
...
Field10

Rather than writing validation for each field individually I want to write a loop that iterates trough each field based on a counting variable after clicking submit, for example:

  1. $count = 0
  2. Do
  3. {
  4.       count++
  5.       if ("Field" + $count == "value") { Do something }
  6. } until ($count == 10)