0

I need to have an multidimensional array as the value of a checkbox kind of like the following.

Any alternatives that will get the same result would be helpful.

<input type="checkbox" name="courses[][coursecode]" value="array("coursecode"=>"MG30012","year"=>"13")" />

Array

Array ( [0] => Array ( [coursecode] => FGB-NNE-MP [year] => 14 ) [1] => Array ( [coursecode] => NUV-PGE-NS [year] => 15 ) )
1

1 Answer 1

0

Yes, I can see why you might want an alternative.

I would suggest that you have a single dimensional array, and pass an easily parsable string to it.

For instance:

<input type="checkbox" name="courses[]" value="MG30012_13" />

And then in your php:

<?php
$courseValues = array(); //multimensional array;

foreach($_POST['courses'] as $course) {
    $courseValues[] = explode('_', $course);
}

?>
1
  • THANKS ALOT. this is exactly what I needed. I really appreciate the help. Commented May 24, 2014 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.