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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.