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);
}
try like this
$arr=$this->input->post('option');
try this
<?php
$arr = $_POST["option"];
foreach($arr as $key => $value){
echo $key.":".$value;
}
?>
$this->input-post('field_name') looks in the $_POST array for a key named 'field_name'. Try this.
$arr=$this->input->post('option[adress]');
foreach($arr as $key => $value)
{
echo($key);
}