我想从表单字段数组中检索数据,我该怎么做
查看:
<li class="checkbox"><input type="checkbox" value="yes" name="options[ac]" id="ac"> <label for="ac">Air Conditioning</label></li>
<li class="checkbox"><input type="checkbox" value="yes" name="options[parking]" id="car"> <label for="car">Car Parking</label></li>
<li class="checkbox"><input type="checkbox" value="yes" name="options[cards]" id="card"> <label for="card">Credit & Debit Card</label></li>
<li class="checkbox"><input type="checkbox" value="yes" name="options[tv]" id="tv"> <label for="tv">TV</label></li>
<li class="checkbox"><input type="checkbox" value="yes" name="options[wifi]" id="wifi"> <label for="wifi">Wi-Fi</label></li>
<li class="checkbox"><input type="checkbox" value="yes" name="options[beverages]" id="beverage"> <label for="beverage">Beverages</labell>
<input name="option[adress]" class="form-control" type="text"
placeholder="Address" required>
<input name="option[email]" class="form-control" type="text" placeholder="email" required>
我想将每个的名称和值显示为: eg.adress:ABCD wifi:是的电子邮件:abcd
如何分配我尝试过的关联数组选项
$arr=$this->input->post('option[]');
foreach($arr as $key => $value)
{
echo($key);
}
答案 0 :(得分:0)
试试这个
$arr=$this->input->post('option');
答案 1 :(得分:0)
试试这个
<?php
$arr = $_POST["option"];
foreach($arr as $key => $value){
echo $key.":".$value;
}
?>
答案 2 :(得分:0)
$ this-&gt; input-post('field_name')在$ _POST数组中查找名为'field_name'的键。试试这个。
$arr=$this->input->post('option[adress]');
foreach($arr as $key => $value)
{
echo($key);
}