Wo0tHigh Posted October 29, 2007 Share Posted October 29, 2007 Below is a multi level array, 0,1,2 is basically a unique id for each question, and below basically validates a correct input, but i cant get it to work!!!! $array=array("0" => array("0" => "Question 1", "1" => array("0" => "Win 1", "1" => "Win 2", "2" => "Win 3", "3" => "Win 4"), "2" => array("0" => "Loose 1", "1" => "Loose 2", "2" => "Loose 3", "3" => "Loose 4")), "1" => array("0" => "Question 2", "1" => array("0" => "Win 1", "1" => "Win 2", "2" => "Win 3", "3" => "Win 4"), "2" => array("0" => "Loose 1", "1" => "Loose 2", "2" => "Loose 3", "3" => "Loose 4")), "2" => array("0" => "Question 3", "1" => array("0" => "Win 1", "1" => "Win 2", "2" => "Win 3", "3" => "Win 4"), "2" => array("0" => "Loose 1", "1" => "Loose 2", "2" => "Loose 3", "3" => "Loose 4"))); if(!in_array_multi($_POST['RadioButton'],$crimeresults)){ echo"Invalid Qestion"; }else{ echo"Valid Question"; } $_POST['RadioButton'] is either 0,1 or 2. For some reason, it always displays "Invalid Question", I cant seem to get my head round it, maybe its because ive been staring at it for too long :| any help would be greatly appreciated!! Thanks, Dan Link to comment https://forums.phpfreaks.com/topic/75270-solved-in_array-multi-level-array/ Share on other sites More sharing options...
Daukan Posted October 29, 2007 Share Posted October 29, 2007 Can you post the in_array_multi() function code? When is $crimeresults set and with what data? Link to comment https://forums.phpfreaks.com/topic/75270-solved-in_array-multi-level-array/#findComment-380724 Share on other sites More sharing options...
teng84 Posted October 29, 2007 Share Posted October 29, 2007 array_key_exists($_POST['RadioButton'],$array); maybe Link to comment https://forums.phpfreaks.com/topic/75270-solved-in_array-multi-level-array/#findComment-380749 Share on other sites More sharing options...
Wo0tHigh Posted October 29, 2007 Author Share Posted October 29, 2007 Hey, sorry the function is ment to be in_array not the one I posted ( I was trying something and forgot the edit ) and array_key_exists worked like a charm!!! Thank you very much guys Link to comment https://forums.phpfreaks.com/topic/75270-solved-in_array-multi-level-array/#findComment-380757 Share on other sites More sharing options...
teng84 Posted October 29, 2007 Share Posted October 29, 2007 ya but put your code around code tags Link to comment https://forums.phpfreaks.com/topic/75270-solved-in_array-multi-level-array/#findComment-380760 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.