Multiple Conditions - IF ELSE

I’m now stumped on muliple conditions in IF THEN statements :frowning:

Hopefully I can explain what I want to achieve!

If $a = ‘1’ and $b>=&c then echo $c
if $a = ‘1’ and $b<$c then echo ‘text’
if $a = ‘2’ or ‘3’ then don’t do anything!

My brain aches and I haven’t a clue how I’d write that in PHP. How exactly do you manage multiple conditions in IF ELSE statements or should I be using something different to achieve this.

Make sense?!! :smiley:

Doh! Is it something really simple like using two IF statements and not doing anything with the third bit?

ETA: But then that still doesn’t answer the multiple conditions bit…argh - who was it said PHP was fun. This is giving me brain meltdown - I need chocolate :wink:

if (($a==1) && ($b >= $c)) {
echo $c;
} else if (($a==1) && ($b < $c)) {
echo ‘text’;

If you have very many conditions, you may find that a switch/case/default construct makes for cleaner code than if/else.

Yep, I recommend using a switch statement:

Thanks for your replies. I’m trying to understand how I would use the switch command for my example and can’t get my head around it. Can anyone help me?

I wouldnt bother using switch:case in this instance, if $a is only ever going to be 1, 2 or 3 you can just test for the value your interested in.

if ($a == 1){
  if ($b>=$c){
    echo $c;
    echo 'text';