donglu5728 2015-10-23 11:53
浏览 24

如何从表单字段数组中检索数据

I want to retrieve data from array of form fields , how do I do it

View:

 <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>

I want to display name and value of each as: eg.adress:abcd wifi :yes email:abcd

how do i assign the associative array option i have tried

    $arr=$this->input->post('option[]');

    foreach($arr as $key => $value) 
    {
        echo($key);
    }
  • 写回答

3条回答 默认 最新

  • douxie7738 2015-10-23 11:56
    关注

    try like this

    $arr=$this->input->post('option');
    
    评论

报告相同问题?