Forum Moderators: coopster
<?php
$retval = '<form name="myform action="post">
<input type="checkbox" name="array1[]" value="elem1" checked >feed1</label><br/>';
$retval .= '<input type="checkbox" name="array1[]" value="elem2" checked >feed2</label><br/>';
$retval .= '<input type="checkbox" name="array2[]" value="elem3" checked >feed3</label><br/>';
$retval .= '<input type="checkbox" name="array3[]" value="elem4" checked >feed4</label></form>';
echo $_POST['array1[]'];
print_r($_POST['array1[]']);
//print_r($array2);
//print_r($array3);
?>
I am trying to print the arrays (array1, array2, and array3) and also how can i join those 3 array elements into 1array?
please help me
thanks
<?php
$retval = '<FORM ACTION="" METHOD="POST">'."\r\n".'
<input type="checkbox" name="array1[]" value="elem1" checked >feed1</label><br/>'."\r\n";
$retval .= '<input type="checkbox" name="array1[]" value="elem2" checked >feed2</label><br/>'."\r\n";
$retval .= '<input type="checkbox" name="array2[]" value="elem3" checked >feed3</label><br/>'."\r\n";
$retval .= '<input type="checkbox" name="array3[]" value="elem4" checked >feed4</label><br/>'."\r\n".'<input type="submit" name="submit" value="submit"></form>'."\r\n";echo $retval;
$joined= array(); //initialize array
for($i=1;$i<4;$i++){
$array = "array$i";
if(isset($_POST[$array])) {
foreach($_POST[$array] as $value){
echo $value."<br>\r\n"; // echo value
$joined[] = $value; // place value into joined array
}
}
}echo "<p><b>Joined Array</b><br>\r\n";
foreach($joined as $value){
echo "$value<br>\r\n";
}
echo "</p>";
?>
2) your action should point to the receiving script. not "POST". change the first line to
$retval = '<form name="myform" action="actionScript.php" method="POST">
[edit] damn mooger beat me to it!