我有这个表单,我正在使用PHP创建。表单元素的名称是数字
<form method="post" action="keywords.php">
<?php
echo $question
?>
</div>
<div class="panel-body">
<?php
foreach ($orderexplode as $o)
{
switch ($o) {
case 0:
print(" " . "<label>" . $presetwords[$i] . "</label>" . " ");
$i++;
break;
case 1:
print(" " . "<input type='text' class='form-control' name='$k' id ='$k'placeholder=" . $responsewords[$k] . ">" . " ");
$k++;
echo $k;
break;
}
}
?>
<br>
<button type='submit' class='btn btn-info'>Submit</button>
</form>
我如何获取每个输入框的值,我想检查它是否与$exploded
字符串匹配?
$string = "Hello How Are You"
$explodedstring = explode(" ",$string)
答案 0 :(得分:0)
您正在尝试使用数组索引。您需要使用索引:
<?php
foreach ($orderexplode as $k => $o)
{
print(" " . "<label>" . $k . "</label>" . " ");
print(" " . "<input type='text' class='form-control' name='" . $k . "' id ='" . $k . "'placeholder=" . $o . ">" . " ");
}
?>