Monday, 9 September 2013

Simplify the expression

Simplify the expression

I am writing a bunch of conditions, using if statements, is there a way to
simplify this to make it look nicer?
$value = "1";
if (($subvalue == 1) && ($subbucket == 1)){
$value = "1";
}
if (($subvalue == 1) && ($subbucket == 2){
$value = "1A";
}
if (($subvalue == 1) && ($subbucket == 3)){
$value = "2A";
}
if (($subvalue == 2) && ($subbucket == 1)){
$value = "3A";
}
if (($subvalue == 2) && ($subbucket == 2)){
$value = "3B";
}
if (($subvalue == 2) && ($subbucket == 3)){
$value = "3C";
}
I find it's messy, is there a way to rewrite this?

No comments:

Post a Comment