chantown Posted June 18, 2009 Share Posted June 18, 2009 Instead of doing this: if($action=="1" || $action=="2" || $action=="6" || $action=="99").. Can I do a shortcut? if($action==[2,6,3])) something like this? Link to comment https://forums.phpfreaks.com/topic/162696-i-want-to-check-if-a-variable-equals-many-things/ Share on other sites More sharing options...
Maq Posted June 18, 2009 Share Posted June 18, 2009 You could whitelist the values, and check $action with with in_array. $action = 3; $valid = array(1,2,3,4,5,6,7); if(in_array($action, $valid)) { echo "true"; } Link to comment https://forums.phpfreaks.com/topic/162696-i-want-to-check-if-a-variable-equals-many-things/#findComment-858600 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.