Jump to content
Larry Ullman's Book Forums

Pass A Multi Dimensional Array To Hidden Forms


Recommended Posts

If you really want to, you can do something like the following:

 

<!DOCTYPE html>

<html lang="en">

 <head>

   <meta charset="UTF-8">

   <title>Test</title>

 </head>

 <body>

   <?php

     if (isset($_POST['submit'])) {

       echo '<pre>';

       print_r($_POST['data']);

       echo '</pre>';

     }

   ?>

   <form action="" method="post">

     <input type="hidden" name="data[]" value="0">

     <input type="hidden" name="data[0][]" value="Cheese">

     <input type="hidden" name="data[0][]" value="Bacon">

     <input type="hidden" name="data[]" value="1">

     <input type="hidden" name="data[1][]" value="Peppers">

     <input type="hidden" name="data[1][]" value="Fork">

     <input type="submit" name="submit" value="Submit">

   </form>

 </body>

</html>

 

However, I'm having trouble coming up with a reason you'd want to do that. As rob said, storing that data in a session would probably be better.

  • Upvote 3
Link to comment
Share on other sites

 Share

×
×
  • Create New...