johno
|- matell
|  L- joky
|     |- alca
|     |- sona
|     |  L- xfish5
|     L- eva
L- droopy
   L- tomo

Grafick‚ koment re
|- RE: Grafick‚ koment re
|  L- RE: RE: Grafick‚ koment re
|     |- RE: RE: RE: Grafick‚ koment re
|     |- RE: RE: RE: Grafick‚ koment re
|     |  |- RE: RE: RE: RE: Grafick‚ koment re
|     |  L- RE: RE: RE: RE: Grafick‚ koment re
|     |     L- RE: RE: RE: RE: Grafick‚ koment re
|     L- RE: RE: RE: Grafick‚ koment re
|        |- RE: RE: RE: RE: Grafick‚ koment re
|        L- RE: RE: RE: RE: Grafick‚ koment re
L- RE: Grafick‚ koment re
   L- RE: RE: Grafick‚ koment re

<?php
$children 
= array(
    
=> array(12),
    
=> array(3),
    
=> array(4),
    
=> array(567),
    
=> array(8)
);

$text = array(
    
=> 'johno',
    
=> 'matell',
    
=> 'droopy',
    
=> 'joky',
    
=> 'tomo',
    
=> 'alca',
    
=> 'sona',
    
=> 'eva',
    
=> 'xfish5',
);


function 
renderPartialTree($id 0$context = array(), $parentLast true) {
    global 
$children$text// nikto nevidi ;-) toto riesenie je len na ukazku algoritmu
    
    
echo implode(''$context).$text[$id]."\n";
    
    
$childs array_key_exists($id$children) ? $children[$id] : array();
    
array_pop($context);
    
    foreach(
$childs as $position => $childId) {
        
$newContext $context;
        
$last = ($position == (count($childs) - 1));
        if(
$id) { // mimo kmena stromu
            
if(!$parentLast) {
                
$newContext[] = '|  ';
            } else {
                
$newContext[] = '   ';
            }
        }
        if(!
$last) {
            
$newContext[] = '|- ';
        } else {
            
$newContext[] = 'L- ';
        }
        
renderPartialTree($childId$newContext$last);
    }
}

echo 
'<pre>';
renderPartialTree();
echo 
'</pre><hr /><pre>';
$children = array(
    
=> array(12),
    
=> array(3),
    
=> array(4),
    
=> array(567),
    
=> array(912),
    
=> array(810),
    
10 => array(11),
);

$text = array(
    
=> 'Grafick‚ koment re',
    
=> 'RE: Grafick‚ koment re',
    
=> 'RE: Grafick‚ koment re',
    
=> 'RE: RE: Grafick‚ koment re',
    
=> 'RE: RE: Grafick‚ koment re',
    
=> 'RE: RE: RE: Grafick‚ koment re',
    
=> 'RE: RE: RE: Grafick‚ koment re',
    
=> 'RE: RE: RE: Grafick‚ koment re',
    
=> 'RE: RE: RE: RE: Grafick‚ koment re',
    
=> 'RE: RE: RE: RE: Grafick‚ koment re',
    
10 => 'RE: RE: RE: RE: Grafick‚ koment re',
    
11 => 'RE: RE: RE: RE: Grafick‚ koment re',
    
12 => 'RE: RE: RE: RE: Grafick‚ koment re',
);

renderPartialTree();
echo 
'</pre><hr />';

highlight_file(__FILE__);
?>