refiking Posted November 24, 2008 Share Posted November 24, 2008 I need to check the $check variable against 5 values. Is there a way to do this other than 5 if statements? Here's what I'm after: <? $check = $_POST['winbot']; //IF winbot = "yellow", "purple", "winbot", "calendar", "circle" //proceed ELSE{ 'Please review your response'; header("Location: index.php"); exit; } ?> Quote Link to comment Share on other sites More sharing options...
flyhoney Posted November 24, 2008 Share Posted November 24, 2008 Thought of using a switch statement? http://us.php.net/switch Quote Link to comment Share on other sites More sharing options...
flyhoney Posted November 24, 2008 Share Posted November 24, 2008 Oh I think I get it. <?php $options = array("yellow", "purple", "winbot", "calendar", "circle"); if (in_array($_POST['winbot'], $options)) { // proceed.... } else { header("Location: index.php"); exit; } ?> 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.