'Undefined offset: 1 (array filter)
I have this arrangement that executes a foreach with the values that a table sends, the problem arises that it is not filtering the empty values and the array and it saves an empty value, that is, if I choose 1 and 4 in my table, it only stores the value of 1 and the second comes out empty.
this is my controller:
$checked_array = $_POST['id_version'];
foreach ($_POST['id_version'] as $key => $value) {
if (in_array($_POST['id_version'][$key], $checked_array))
{
$soft_instal = new Software_instalacion;
$soft_instal->id_instalacion = $instalaciones->id;
$soft_instal->id_historial = $historial->id;
$soft_instal->id_usuario = $request->id_usuario;
$soft_instal->id_version = $_POST['id_version'][$key];
$soft_instal->obs_software = $_POST['obs_software'][$key];
$soft_instal->id_tipo_venta = $_POST['id_tipo_venta'][$key];
$soft_instal->save();
}
}
this is my view: enter image description here
I would like to know how I can filter those empty values of obs_software and id_tip_venta, that is, how can I apply the filter array
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
