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; } ?> Link to comment https://forums.phpfreaks.com/topic/134080-solved-check-variable-against-5-values/ 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 Link to comment https://forums.phpfreaks.com/topic/134080-solved-check-variable-against-5-values/#findComment-697948 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; } ?> Link to comment https://forums.phpfreaks.com/topic/134080-solved-check-variable-against-5-values/#findComment-697952 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.