wwedude Posted August 25, 2008 Share Posted August 25, 2008 Hello, How would I create a code where the if condition is multiple variables? For example: if variable=3 AND anothervariable=5 then echo "something", elseif variable=3 AND anothervariable=2 then echo "somethingelse" Of course that was just me rambling on, and not my attempt at a php code. Thanks for any and all help! Link to comment https://forums.phpfreaks.com/topic/121284-solved-simple-ifelse-question/ Share on other sites More sharing options...
budfroggy Posted August 25, 2008 Share Posted August 25, 2008 if( $var == 3 && $othervar == 5 ) { echo "something"; } elseif( $var == 3 && $othervar = 2 ) { echo "Something else"; } Remember, you can also nest if statements: if( $var == 3 ) { if( $othervar == 5 ) { echo "someting"; } elseif( $othervar == 2 ) { echo "something else"; } } Link to comment https://forums.phpfreaks.com/topic/121284-solved-simple-ifelse-question/#findComment-625271 Share on other sites More sharing options...
efficacious Posted August 25, 2008 Share Posted August 25, 2008 alil more clear explaination.. for OR's if($Variable=='This' OR $Variable=='This') { //DO THIS } //OR YOU CAN DO THIS if($Variable=='This' || $Variable=='This') { //DO THIS } for and's if($Variable=='This' AND $Variable=='This') { //DO THIS } //OR if($Variable=='This' && $Variable=='This') { //DO THIS } Link to comment https://forums.phpfreaks.com/topic/121284-solved-simple-ifelse-question/#findComment-625275 Share on other sites More sharing options...
wwedude Posted August 25, 2008 Author Share Posted August 25, 2008 Thank you all - topic sovled. Link to comment https://forums.phpfreaks.com/topic/121284-solved-simple-ifelse-question/#findComment-625295 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.