Source Code:
(back to article)
<?php $cart = array( array("name" => "Product 1", "price" => 10), array("name" => "Product 2", "price" => 20), array("name" => "Product 3", "price" => 30) ); $prices = array_column($cart, "price"); $total_price = array_sum($prices); echo "The total price of the items in the cart is: $" . $total_price; ?>
Result:
Report an issue