scott212 Posted January 15, 2007 Share Posted January 15, 2007 is there any way to evaluate multiple values in an 'if' condition? Example: if ($value != 1,2,3,4) or if ($value == 1||2||3||4||)Do you know of anything like this? I can't seem to find anything on google. Sure would clean up some code Quote Link to comment Share on other sites More sharing options...
owenjh Posted January 15, 2007 Share Posted January 15, 2007 You can evaluate multiple conditions by doing the following:if ($var == 1 || $var == 2 || $var == 3) {} Quote Link to comment Share on other sites More sharing options...
Orio Posted January 15, 2007 Share Posted January 15, 2007 There are few ways doing it... Here are two I can think of:[code]<?php//first way, the regular wayif($value == 1 || $value == 2 || $value == 3 || $value == 4)//second way, using an array and in_array()if(in_array($value, array(1,2,3,4)))?>[/code]Orio. Quote Link to comment Share on other sites More sharing options...
scott212 Posted January 15, 2007 Author Share Posted January 15, 2007 wow - I can't believe how quick to respond this community is. You suggestions are great, thank you! (I think I like the regular way for clarity reasons) 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.