"Notice: Undefined variable" error and foreach loop
<p>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?</p>

<p>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?</p>

<pre><code>switch( $_SESSION['shippingMethod'] )
{
  case "Air": 
             $shipping = $subtotal * 0.1;
             break;
}
</code></pre>

<p>and</p>

<pre><code>foreach( $cart as $cartKey =&gt; $cartItem )
{
    $subtotal += $cartItem['total'];
}
</code></pre>

<p>Thank you very much in helping.</p>
