how do I loop through this array and assign the values to a variable and save it to MySQL?
the following array was generated using this form. I don't want to use index keys as the number of values may increase or decrease.
<input type="text" name="formB[usr_f_name][]" placeholder="First Name" />
<input type="text" name="formB[usr_l_name][]" placeholder="Last Name" />
<input type="text" name="formB[usr_mobile][]" placeholder="Mobile Number" />
Array
(
[usr_f_name] => Array
(
[0] => first
[1] => second
)
[usr_l_name] => Array
(
[0] =>
[1] =>
)
[usr_mobile] => Array
(
[0] =>
[1] =>
)
[usr_email] => Array
(
[0] =>
[1] =>
)
)
This is what I have at the moment. but can't get it working
$id_array = array_keys($_POST['formB']);
foreach ($id_array as $id){
$usr_f_name = mysqli_real_escape_string ($_POST['usr_f_name'][$id]);
$usr_l_name = mysqli_real_escape_string ($_POST['usr_l_name'][$id]);
$usr_mobile = mysqli_real_escape_string ($_POST['usr_mobile'][$id]);
$sql = "INSERT INTO formB SET f_name = '$usr_f_name', l_name = '$usr_l_name', mobile ='$usr_mobile'";
}
$id_arraycoming from?