What potential issue can arise when calculating the total price of items in the shopping cart?

One potential issue that can arise when calculating the total price of items in the shopping cart is the risk of encountering floating-point precision errors. To solve this issue, it is recommended to use PHP's number_format() function to format the final total price to a specified number of decimal places.

// Calculate the total price of items in the shopping cart
$totalPrice = 0;
foreach ($cartItems as $item) {
    $totalPrice += $item['price'] * $item['quantity'];
}

// Format the total price to 2 decimal places
$totalPrice = number_format($totalPrice, 2);

echo "Total Price: $" . $totalPrice;