function toLista($orga, $li_estilo, $ul_estilo)
{
    $htm = "<li class='{$li_estilo}'>";
    if (trim($orga['url']) != "") {
        $htm = "{$htm} <a href='" . $orga['url'] . "'>" . $orga['funcion'] . " " . $orga['titulo'] . "</a>";
    } else {
        $htm = "{$htm}" . $orga['funcion'] . " " . $orga['titulo'];
    }
    if (trim($orga['glosa']) != "") {
        $htm = "{$htm}: <i>" . $orga['glosa'] . "</i>";
    }
    $hijos = $orga['hijos'];
    if ($hijos != array()) {
        for ($i = 0; $i < count($hijos); $i++) {
            $htm = $htm . toLista($hijos[$i], $i < count($hijos) - 1 ? "" : "fin", "menu");
        }
    }
    $htm = $htm . "</li>\n";
    return acentosHTML("<ul class='{$ul_estilo}'>\n{$htm}\n</ul>\n");
}
<?php

require_once "common-org.php";
if ($depurar != 1) {
    header("Content-Disposition: attachment; filename=organica.html");
}
$_SESSION['organica'] = 'SI';
org_header("Estructura Org&aacute;nica, " . $_SESSION['nombre']);
echo toLista($_SESSION['data'], "", "primer_nodo");
echo html_volver("index.html");
html_footer("codigo" . trim(alfanum($_SESSION['sigla'])) . " organica " . date('Y-m-d'));