How can PHP be used to efficiently handle different shipping options and quantities for a customer's order?

To efficiently handle different shipping options and quantities for a customer's order in PHP, you can create a form where customers can select their desired shipping option and quantity. Upon form submission, you can use PHP to calculate the total cost based on the selected shipping option and quantity.

<?php
// Get the selected shipping option and quantity from the form
$shippingOption = $_POST['shipping_option'];
$quantity = $_POST['quantity'];

// Define shipping costs for each option
$shippingCosts = [
    'standard' => 5,
    'express' => 10,
    'next_day' => 15
];

// Calculate total cost based on selected shipping option and quantity
$totalCost = $shippingCosts[$shippingOption] * $quantity;

// Display the total cost to the customer
echo "Total cost for shipping option $shippingOption and quantity $quantity: $totalCost";
?>