title: Should I unset both `$key` and `$value` after every foreach statement?
body: <p>All the answers I've found only talk about unsetting <code>$value</code> except one, which wasn't clear to me.  So here I am. Say I have the line:</p>
  
  <pre><code>foreach ($data as $key =&gt; $value)
      {
      // do stuff
      }
  </code></pre>
  
  <p>Should I put these two lines after?</p>
  
  <pre><code>unset($key);
  unset($value);
  </code></pre>
  
  <p>Or can I omit <code>unset($key)</code>?  Also, is it recommended to ALWAYS use unset after every <code>foreach</code>?  Say I have nested <code>foreach</code> loops, like this:</p>
  
  <pre><code>foreach ($data as $key =&gt; $value)
      {
          foreach ($data[$key] as $key =&gt; $value)
          {
          // do stuff
          }
          unset($key);
          unset($value);
      }
      unset($key);
      unset($value);
  </code></pre>
  
  <p>Would the nested <code>unset()</code> functions interfere with the highest level <code>foreach</code>?  In other words, are the nested <code>$key</code> and <code>$value</code> the same as the highest level <code>$key</code> and <code>$value</code>?</p>