Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created October 25, 2022 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/6477c83cdffc1aa1362f0240eb7fc59c to your computer and use it in GitHub Desktop.
Save parzibyte/6477c83cdffc1aa1362f0240eb7fc59c to your computer and use it in GitHub Desktop.
<?php
$nombres = $_POST["nombres"];
$marcas = $_POST["marcas"];
$precios = $_POST["precios"];
$subtotal = 0;
for ($i = 0; $i < count($nombres); $i++) {
$nombre = $nombres[$i];
$marca = $marcas[$i];
$precio = floatval($precios[$i]);
$subtotal += $precio;
printf("%s ($%s) marca %s<br>", $nombre, number_format($precio, 2), $marca);
}
$porcentajeIva = 0.16;
$iva = $subtotal * $porcentajeIva;
$total = $subtotal + $iva;
echo "<br><strong>Subtotal: </strong>$" . number_format($subtotal, 2) . "<br>";
echo "<strong>IVA: </strong>$" . number_format($iva, 2) . "<br>";
echo "<strong>TOTAL: </strong>$" . number_format($total, 2) . "<br>";
echo "<br><a href=''>Volver al formulario</a>";
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment