title: Creating Subdirectories with a for loop
body: <pre><code> $product_Category = ' Electronics| Computers &amp; Accessories| Monitors ';   
  
  &lt;!-- a simple div with some links --&gt; 
      &lt;div class="breadcrumb-killer flat"&gt;
          &lt;a href="index.php" class="active"&gt;Home&lt;/a&gt;
          &lt;?php 
          $cats = explode("|",  $product_Category);
          for($k = 0; $k &lt; count($cats); $k++) {
              for ($l=0; $l &lt;= $k; $l++) { 
                  $folder = permalink($cats[$l])."/" ;
                  echo $folder;
              }
  
              echo '&lt;a href="'.$folder.'"&gt;'.$cats[$k].'&lt;/a&gt;';
          } 
          ?&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>I have categories separated with a delimeter as - Electronics| Computers &amp; Accessories| Monitors</p>
  
  <p>Am creating clean urls with this function </p>
  
  <pre><code>function permalink($var)
  {
      $var = preg_replace('#([\W_]+)#', ' ', $var);
      $var = str_replace(' ', '-', $var);
      $var = strtolower($var);
      $var = rtrim($var, '-');
      $var = ltrim($var, '-'); 
      $var = trim($var);
      return $var;
  }
  </code></pre>
  
  <p>when i output folder am getting this :</p>
  
  <pre><code>electronics/  electronics/computers-accessories/ electronics/computers-accessories/monitors/
  </code></pre>
  
  <p>Though the urs aren't constructed the way i want .
  Am expecting urls to be like :</p>
  
  <pre><code>&lt;a href="electronics/"&gt;Electronics&lt;/a&gt;
  &lt;a href="electronics/computers-accessories/"&gt;Computers &amp; Accessories&lt;/a&gt;
  &lt;a href="electronics/computers-accessories/monitors/"&gt;Monitors&lt;/a&gt;
  </code></pre>
  
  <p>this is what i am getting :</p>
  
  <pre><code>    &lt;a href="electronics/"&gt;Electronics&lt;/a&gt;
      &lt;a href="computers-accessories/"&gt; Computers &amp;amp; Accessories&lt;/a&gt;
      &lt;a href="monitors/"&gt; Monitors&lt;/a&gt;
  </code></pre>