How to get Array Position State with digitalRead ?

Delta_G:
Throw a serial print inside that for loop to prove to yourself that it is running or not.

In my protoboard I have selected option 1, but serial monitor displays the four options as "1" like:

2 - 4 - 1
3 - 4 - 1
4 - 4 - 1
5 - 4 - 1

The switch is entering case: 4. I believe the state is not changing the "var" variable, the for is just looping until the end and "var" gets equal 4.

for(int i = 0; i < 4; i++){
    if(digitalRead(dipPins[i]) == 0){
      var = i + 1;
    }
    Serial.print(dipPins[i]);
    Serial.print(" - ");
    Serial.print(var);
    Serial.print(" - ");
    Serial.println(digitalRead(dipPins[i]));
  }

I tried with the following if-else if statement and isn't working too. It catch the "var" the first time, but later didn't recognize the dip switch change at runtime.

if(digitalRead(dipPins[0]) == 0){
    var = 1;
  }
  else if(digitalRead(dipPins[1]) == 0){
    var = 2;
  }
  else if(digitalRead(dipPins[2]) == 0){
    var = 3;
  }
  else if(digitalRead(dipPins[3]) == 0){
    var = 4;
  }

6v6gt:
For a choice of 4 values of var , you need only 2 dip switches. 4 dip switches actually gives you 16 cases..

I thought to received HIGH/LOW or 0/1 only. In which case yes, i can use only 2. I'll change that at the end! Thanks!