// I create the variable array session
session_start();
$fact = [0 => 0];
$_SESSION['facturacion'] = $fact;
// I pick it up in another file
include 'cn.php';
session_start();
$fact = $_SESSION['facturacion'];
$total = 0;
if(isset($_POST['e']) && isset($_POST['c']))
{
$id = $_POST['e'];
$cantidad = $_POST['c'];
if(count($_SESSION['facturacion']) <= 8){
for ($i=0; $i < count($_SESSION['facturacion']); $i++) {
if (!(in_array($id, $fact))) {
$resultado1 = mysqli_query($link, "SELECT * FROM productos WHERE ID =
$id") or die();
$fila1 = mysqli_fetch_array($resultado1);
if ($fila1['ProductS'] >= $cantidad) {
$fact[$id] = $cantidad;
$_SESSION['facturacion'] = $fact;
}
}
}
}
}
$precio = 1;
foreach ($fact as $key => $value) {
$resultado = mysqli_query($link, "SELECT * FROM productos WHERE ID = $key")
or die();
$fila = mysqli_fetch_array($resultado);
$precio = $fila['ProductP'];
$total+=$value*$precio;
if ($key != 0) {
$Subtotal = $precio*$value;
$p = strpos($precio, ".");
if($p === false){$Subtotal = $Subtotal.".00";}else{$Subtotal =
$Subtotal."0";}
$salida.= "
<tr>
<td>".$value."</td>
<td>".$fila['ProductU']."</td>
<td>".$fila['ProductN']."</td>
<td>".$fila['ProductP']."</td>
<td>".$Subtotal."<span aria-hidden='true'>×</span></td>
</tr>";
}
}
echo $salida;
mysqli_close($link);
I want to create the variable in the second file, but when I try it I can not, and I can not stop using [0 = > 0]; because I get an error, my question is As I create the array in the second file and save that array in $ _SESSION