Can someone please explain to me why I get "Notice: Undefined variable" for variable $subtotal in the 2nd code snippet but NOT in the 1st code snippet ? What's the difference between them? Are they consider local variables?
Also, exactly what is the variable type (Global, Superglobal.. etc) of $cartKey and $cartItem in the foreach loop? How come I didn't need to define/declare them?
switch( $_SESSION['shippingMethod'] )
{
case "Air":
$shipping = $subtotal * 0.1;
break;
}
and
foreach( $cart as $cartKey => $cartItem )
{
$subtotal += $cartItem['total'];
}
Thank you very much in helping.
$subtotal = $subtotal + $cartItem['total'];