Darkwoods Posted February 16, 2010 Share Posted February 16, 2010 im trying to have different values but i don't know how to separate them, i tried with , . 'AND' but still not working with me i googeled it but could not find any examples thanks <?php if($var == 'value1' or 'value2' or 'value3') { echo 'Lets echo it!'; } ?> Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 16, 2010 Share Posted February 16, 2010 if($var == 'value1' or $var == 'value2' or $var == 'value3') or if($var == 'value1' || $var == 'value2' || $var == 'value3') Quote Link to comment Share on other sites More sharing options...
Darkwoods Posted February 16, 2010 Author Share Posted February 16, 2010 ah thanks it worked just one question u cant seperate the values somethin like that $var == 'value1', 'value2', 'value3', etc in PHP? anyway thanks Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 16, 2010 Share Posted February 16, 2010 no, you have to give the 2 sides of the comparison each time Quote Link to comment Share on other sites More sharing options...
Thierry Posted February 16, 2010 Share Posted February 16, 2010 There's always the option to use an array and check with in_array or something like that. Don't know about performance and such though. if(in_array($var,array("value1","value2","value3)) { } Quote Link to comment Share on other sites More sharing options...
Darkwoods Posted February 16, 2010 Author Share Posted February 16, 2010 thanks Quote Link to comment Share on other sites More sharing options...
berridgeab Posted February 16, 2010 Share Posted February 16, 2010 switch statement too : Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.