我想获取与所选复选框对应的多个文本框值...我们可以一次选择一个或多个复选框,然后单击按钮,我需要的输出如下所示:假设我的数组是这样的:数组1("第一","第二","第三");array2('a','b','c','d','e','f','g','h','i').我需要的输出是:-
第一,A,B,C
第二,d,e,f
第三,克,高,一
请建议我!!这是我的演示代码:
<?php
if(isset($_REQUEST["button7"]))
{
if(isset($_POST['check1']))
{
if (is_array($_POST['check1']))
{
foreach($_POST['check1'] as $key=> $value)
{
echo "<br>checkbox value is $key :". $value;
if (is_array($_POST['hindi']))
{
foreach($_POST['hindi'] as $value)
{
echo "<br>".$value;
}
}
}
}
}
}
?>
<form name="files" action="demp.php" method="post">
<table width="300" border="1" >
<tr>
<th>check value</th>
<th>English Name</th>
<th>Hindi Name</th>
<tr>
<?php
for($i=0;$i<10;$i++)
{?>
<td><input name="check1[]" class="checkbox2" type="checkbox" id="check1" value="<?php echo "checkboxvalue = ".$i;?>" /></td>
<td><input type="text" value="" name="hindi[]" id="txt1"></td>
<td><input type="text" value="" name="hindi[]" id="txt2"></td></tr>
<?php
}
?>
</table>
<input type="submit" name="button7" value="edit_pdf">
您可以使用
array_chunk
和array_merge_recursive
$array1 = array('first', 'second', 'third');
$array2 = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i');
$first = array_chunk($array1,1);
$second = array_chunk($array2, 3);
foreach($first as $key => $value){
$result[] = array_merge($value,$second[$key]);
}
print_r($result);
小提琴