Adding variables to number if they are equal to a certain number or not

I have 3 variables where I want to add them to a number in different ways depending on the variables value. lets say I have variables $a $b and $c

I want to say add variables $a and $b only to my original number as long as $a is not equal to 2, if $a is equal to 2 I want to only add $a and $c to my number.

Can someone show me how to write that function in php?

[php]$originalnumber = 50;

if($a == 2){
// Do Nothing
}else{
$changednumber = $originalnumber + $a + $c;
}

echo $changednumber;[/php]

Give more variations on what you want to happen and code will change.

Sponsor our Newsletter | Privacy Policy | Terms of Service