How can the code snippet be improved for better readability and maintainability in PHP?

The code snippet can be improved for better readability and maintainability by using meaningful variable names, breaking down complex logic into smaller functions, and adding comments to explain the purpose of each section of code.

// Improved code snippet with better readability and maintainability

function calculateTotalPrice($products) {
    $totalPrice = 0;

    foreach ($products as $product) {
        $price = $product['price'];
        $quantity = $product['quantity'];
        $subtotal = $price * $quantity;
        $totalPrice += $subtotal;
    }

    return $totalPrice;
}

$products = [
    ['name' => 'Product A', 'price' => 10, 'quantity' => 2],
    ['name' => 'Product B', 'price' => 20, 'quantity' => 1],
    ['name' => 'Product C', 'price' => 15, 'quantity' => 3]
];

$totalPrice = calculateTotalPrice($products);
echo "Total price: $totalPrice";