I have a function inside a class, and within that function I have the following vector:
$compra = [
"produto" => "Chocolate Nestle",
"preco" => 5.5,
"frete" => 1.5,
"total" => $compra['preco'] + $compra['frete']
];
I need to make the sum of the price and freight within the vector itself, I use var_dump
to show me the result and this error happens:
var_dump ($ purchase);
NOTICE Undefined variable: compra on line number 10
NOTICE Undefined variable: compra on line number 10
array(4) { ["produto"]=> string(16) "Chocolate Nestle" ["preco"]=> float(5.5) ["frete"]=> float(1.5) ["total"]=> int(0) }
line 10 is the line that makes the sum