Jump to content

[SOLVED] in_array & multi level array...


Wo0tHigh

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.