Log 2030
04/09/2023 2023-09-04 13:43$products = array(); // Create an empty array to store the products
// Loop to create a group of fields for the products
for ($i = 0; $i ”, // Placeholder for product name
‘price’ => 0, // Placeholder for product price
‘quantity’ => 0 // Placeholder for product quantity
);
$products[] = $product; // Add each product to the array
}
return json_encode($products); // Convert the array to JSON format and return it as a list
$totalAmount = 0; // Variable to store the total amount
// Loop through each product and calculate its total price (price * quantity)
foreach ($products as $product) {
$totalAmount += ($product[‘price’] * $product[‘quantity’]);
}
return “Total Amount: ” . number_format($totalAmount, 2); // Echo the total amount with proper formatting