I am using foreach over an array and adding each member and assigning total to a variable.
It works like i want, but I get the error:
Notice: Undefined variable: total in C:\xampp\htdocs\preg.php on line 10
I dont quite understand how/why this works and why I get the ^^ error
<?php
$bar = [1,2,3,5,36];
foreach($bar as $value) {
$total = ($total += $value);
}
echo $total;
?>