title: PHP script to traverse directory/file tree and output tree as nested ULs
body: <p>I have a tree of directories, sub-directories, and files (in some but not all the directories).  Here's an example of the whole tree:</p>
  
  <pre><code>/food
  /food/drinks
  /food/drinks/water.html
  /food/drinks/milk.html
  /food/drinks/soda.html
  /food/entrees
  /food/entrees/hot
  /food/entrees/hot/hamburger.html
  /food/entrees/hot/pizza.html
  /food/entrees/cold
  /food/entrees/cold/icecream.html
  /food/entrees/cold/salad.html
  /cosmetics
  /cosmetics/perfume
  /cosmetics/perfume/chic.html
  /cosmetics/perfume/polo.html
  /cosmetics/perfume/lust.html
  /cosmetics/lipstick
  /cosmetics/lipstick/colors
  /cosmetics/lipstick/colors/red.html
  /cosmetics/lipstick/colors/pink.html
  /cosmetics/lipstick/colors/purple.html
  </code></pre>
  
  <p>OK, From a php script in the '/' directory, I want to recurse or traverse this directory tree and print the tree like this:</p>
  
  <pre><code>&lt;ul&gt;
    &lt;li&gt;food&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;drinks&lt;/li&gt;
          &lt;ul&gt;
            &lt;li&gt;water.html&lt;/li&gt;
            &lt;li&gt;milk.html&lt;/li&gt;
            &lt;li&gt;soda.html&lt;/li&gt;
          &lt;/ul&gt;
        &lt;li&gt;entrees&lt;/li&gt;
          &lt;ul&gt;
            &lt;li&gt;hot&lt;/li&gt;
              &lt;ul&gt;
                &lt;li&gt;hamburger.html&lt;/li&gt;
                &lt;li&gt;pizza.html&lt;/li&gt;
              &lt;/ul&gt;
            &lt;li&gt;cold&lt;/li&gt;
              &lt;ul&gt;
                &lt;li&gt;icecream.html&lt;/li&gt;
                &lt;li&gt;salad.html&lt;/li&gt;
              &lt;/ul&gt;      
          &lt;/ul&gt;
      &lt;/ul&gt;
    &lt;li&gt;cosmetics&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;perfume&lt;/li&gt;
          &lt;ul&gt;
            &lt;li&gt;chic.html&lt;/li&gt;
            &lt;li&gt;polo.html&lt;/li&gt;
            &lt;li&gt;lust.html&lt;/li&gt;
          &lt;/ul&gt;
        &lt;li&gt;lipstick&lt;/li&gt;
          &lt;ul&gt;
            &lt;li&gt;colors&lt;/li&gt;
              &lt;ul&gt;
                &lt;li&gt;red.html&lt;/li&gt;
                &lt;li&gt;pink.html&lt;/li&gt;
                &lt;li&gt;purple.html&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/ul&gt;
      &lt;/ul&gt;
  &lt;/ul&gt;
  </code></pre>