eğer / anahtarı - "$ var 'a' veya 'b' veya 'c' ise"

0 Cevap php

Possible Duplicate:
PHP make if shorter

Şöyle bir if bildirimde:

if($variable == "one" || $variable == "two" || $variable == "three" || $variable == "four"){
    // do something
}
else {
    // do something else
}

sorun olduğunu, onun oldukça iri oluyor .. onun yaklaşık 20 veya 30 farklı seçenek olacak.

Ben daha az kod yapabilirsiniz yine de var mı? EG:

if($variable == ("one" || "two" || "three" || "four" || "five"))..

0 Cevap