jonniejoejonson Posted April 29, 2010 Share Posted April 29, 2010 Is there a shorter way to write... if($name=='dave'||$name=='thomas'||$name=='steve'){ } Quote Link to comment Share on other sites More sharing options...
ignace Posted April 29, 2010 Share Posted April 29, 2010 if (in_array($name, array('dave','thomas','steve')) shorter but I doubt it's faster Quote Link to comment Share on other sites More sharing options...
jonniejoejonson Posted April 29, 2010 Author Share Posted April 29, 2010 Thanks ignance, I thught you might be able to write something like: if($name==('dave'||'thomas'||'steve')){ } but apparently not. Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted April 29, 2010 Share Posted April 29, 2010 Nope that's as good as it gets jonnie Quote Link to comment Share on other sites More sharing options...
Roopa Lakhlani Posted April 29, 2010 Share Posted April 29, 2010 $name_list = array('dave','thomas','steve); $read_name = 'steve'; if (in_array($read_name,$name_list) { echo "hello" .$read_name; } Quote Link to comment Share on other sites More sharing options...
jonniejoejonson Posted April 29, 2010 Author Share Posted April 29, 2010 Thanks guys. 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.