simon551 Posted May 11, 2009 Share Posted May 11, 2009 Hi. Having a mental block. Can you help me write: if (a=true) { if (b=true) { foo; } else (neither a nor b = true) { do something; } } I'm stuck on the the else part. the way it is written, the else is based on a=true. but I want it to be based on both a and b. ? Link to comment https://forums.phpfreaks.com/topic/157745-solved-if-then-if-else-neither/ Share on other sites More sharing options...
gevans Posted May 11, 2009 Share Posted May 11, 2009 <?php if(a) { //a is true } elseif(b) { //b is true } else { //neither are true } Link to comment https://forums.phpfreaks.com/topic/157745-solved-if-then-if-else-neither/#findComment-832001 Share on other sites More sharing options...
simon551 Posted May 11, 2009 Author Share Posted May 11, 2009 thanks but I really need (a) and (b) to be true. Maybe I should have stated the question: if (a and b) then, else. if (a) { if (b) { x } } else { [y]} I'm going after that x space where both a and b are true and also need to know if both are not true. I don't particularly care if just one of a or b is true. Link to comment https://forums.phpfreaks.com/topic/157745-solved-if-then-if-else-neither/#findComment-832008 Share on other sites More sharing options...
gevans Posted May 11, 2009 Share Posted May 11, 2009 <?php if(a && b) { //a and b are true } elseif(!a && !b) { //a and b are false } else { //one is true and one is false } Link to comment https://forums.phpfreaks.com/topic/157745-solved-if-then-if-else-neither/#findComment-832012 Share on other sites More sharing options...
simon551 Posted May 11, 2009 Author Share Posted May 11, 2009 thank you! Link to comment https://forums.phpfreaks.com/topic/157745-solved-if-then-if-else-neither/#findComment-832018 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.