Esempio n. 1
0
function echoTree($trees, $childs, $node, $n = 0)
{
    echo '<li><a href="' . Yii::app()->createUrl('/project/chat', array('orderId' => $node)) . '">' . $node . ': ' . $trees[$node] . '</a>';
    if (count($childs[$node])) {
        foreach ($childs[$node] as $child) {
            echo '<ul>';
            echoTree($trees, $childs, $child, $n + 1);
            echo '</ul>';
        }
    }
    echo '</li>';
}
Esempio n. 2
0
function echoTree($array)
{
    global $i;
    foreach ($array as $k => $v) {
        if (is_array($v)) {
            $myIndice = $i++;
            echo "<div class='spoiler' data-spoiler-link='{$myIndice}'>{$k}: <button type='button' class='button'>Open</button></div>";
            echo "<ul class='spoiler-content' data-spoiler-link='{$myIndice}'>";
            echoTree($v);
            echo "</ul>";
        } else {
            $short = end(explode("\\", $k));
            echo "<li><input type='radio' name='event' value='{$k}'><strong>{$short}</strong>: {$v}</li>";
        }
    }
}
Esempio n. 3
0
<?php

function echoTree($n)
{
    echoTreeR($n, $n);
}
function echoTreeR($n, $maxN)
{
    if ($n < 1) {
        return;
    }
    echoTreeR($n - 1, $maxN);
    echoWS($maxN - $n);
    for ($i = 0; $i < 2 * $n - 1; $i++) {
        echo "*";
    }
    echoWS($maxN - $n);
    echo "\n";
}
function echoWS($numWS)
{
    for ($i = 0; $i < $numWS; $i++) {
        echo " ";
    }
}
echoTree(4);