sugan Posted February 15, 2008 Share Posted February 15, 2008 I have an array of values and i am trying to send the array values with a hidden input field from a form to another script.How can this be done? <input type=hidden name=array value="<?php echo $arrayname;?>"> I want to post the array values in another php page.Is this possible?Regards,Sugan Link to comment Share on other sites More sharing options...
jhecht Posted February 15, 2008 Share Posted February 15, 2008 Never tried this working with a hidden element, but i think something like this would work(make sure this is inside a form tag or something) <?foreach($array as $value){ echo "<input type=\"hidden\" name=\"ElementArray[]" value=\"$value\" />\n";}?> in the next page, the $_POST data would have ElementArray as an array... I think. I know it works for checkboxes. never tried it with hidden inputs. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 18, 2008 Share Posted February 18, 2008 You can also do this: <?php$array = array( 0 => "zero", 1 => "one", 2 => "two", "sky" => "blue", "grass" => "green");echo "<input type=\"hidden\" name=\"ar\" value=\"" . base64_encode(serialize($array)) . "\">";?> <?php$array = unserialize(base64_decode($_POST['ar']));print_r($array);?> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.