Loops + Arrays = ForEach -- why unset $lang?


#1

Hi - Why do we need to unset $lang in this example? Is that common practice, to unset variables when you're done using them?:







Languages you can learn on Codecademy:




    <?php
    $langs = array("JavaScript",
    "HTML/CSS", "PHP",
    "Python", "Ruby");
      foreach ($langs as $lang) {
          echo "<li>$lang</li>";
      }

      unset($lang);
    ?>
  </ul>
</div>



#2

@mckenna33,
IMHO the unset() is not needed in this case....
read the manual
http://php.net/manual/en/control-structures.foreach.php