English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want to execute some code in php only if two if statements are true.

e.g. if $a = a and $b = b then do {...1...} else do {...2...}

And I want to make it so there are three possibilities:

e.h. if $a = a1, a2 or a3 and $b = b1, b2 or b3 (respectively) then do {...1...} else do {...2...}.

I want to code this in PHP and {...1...} should only be executed in the following instances:

When $a = a1 and $b = b1
When $a = a2 and $b = b2
When $a = a3 and $b = b3

But {...2...} should be executed at all other times i.e. when

When $a = a1 and $b = b2
When $a != a1 and $b = b1
When $a = a3 and $b = b1
When $a = a2 and $b != b1
etc...

Can anyone help me with this?

2006-10-30 02:54:07 · 2 answers · asked by turkeyphant 3 in Computers & Internet Programming & Design

2 answers

You use && for AND and || for OR. So your if statement would be like
if ((($a==a1)&&($b==b1))||
(($a==a2)&&($b==b2))||
(($a==a3)&&($b==b3))){...

2006-10-30 04:41:42 · answer #1 · answered by injanier 7 · 1 0

hmmmm

2006-10-30 02:55:57 · answer #2 · answered by MUTANT 2 · 0 1

fedest.com, questions and answers