PHP function generate UL LI
        Posted  
        
            by apis17
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by apis17
        
        
        
        Published on 2010-03-16T05:30:06Z
        Indexed on 
            2010/03/16
            5:36 UTC
        
        
        Read the original article
        Hit count: 579
        
hi.. i'm referring this address for function olLiTree
http://stackoverflow.com/questions/753853/php-function-that-creates-a-nested-ul-li
i have this array
$tree = array("A"=>array("B"=>array("C"=>"C","D"=>"D"),"E"=>array("F"=>"F","G"=>"G")));
but not able to use this function
function olLiTree($tree)
{
    echo '<ul>';
    foreach($tree as $item) {
        if (is_array($item)) {
            olLiTree($item);
        } else {
            echo '<li>', $item, '</li>';
        }
    }
    echo '</ul>';
}
to generate
<ul>
  <li>A</li>
  <li>B
    <ul>
      <li>C</li>
      <li>D</li>
    </ul>
  </li>
  <li>E
    <ul>
      <li>F
      </li>
    </ul>
  </li>
  <ul>
    <li>G</li>
  </ul>
</ul>
can anybody help me to fix this? thanks..
© Stack Overflow or respective owner