I am creating hidden form field variable names using a 'for' loop (example 1) on page1.php and it passes the variables through a form post to page2.php, so that when they are received by page2.php they are defined as $recipient1, $recipient2, etc...
My question, I have potentially 500 variables being sent via hidden form fields with the same naming convention, is there a way to dump the value of $recipient1 into $recipient[1] using a for loop or do i have to assign them individually.
EXAMPLE 1
<? for ($y=0; $y < count($data); $y++) { ?>
<input type="checkbox" name="recipient<? echo $y; ?>" value="<? echo $name; ?>">
<? } ?>
How to convert hidden form variables into an array
Moderator: General Moderators
trynotice chkbox[]
Code: Select all
<html><body><form method="POST">
<?php
for ($i=0; $i!=10;$i++)
echo '<input type="checkbox" name="chkboxї]" value="', $i, '" />',$i,'<br/>';
?>
<input type="submit" />
</form>
<fieldset><legend>posted values</legend>
<pre><?php print_r($_POST) ?></pre>
</fieldset>
</body></html>