Ho provato a buttare giu qualche cosa tuttavia non riesco a capire come poter prasare il codice in entrata

Codice PHP:
    class template
    
{
        public    
$__tags = array();
        
        private    
$__file,
                
$__options = array('loop''if''noprase');
        
    
    
//------------------------------------------------------------------------
    // costruttore della classe
    //------------------------------------------------------------------------            
        
function __construct($file)
        {
            if (!empty(
$file))
            {
                if (
file_exists($file))
                { 
                    
$this->__file file_get_contents($file);
                } else
                    
$this->error('Il file [{$file}] non esiste!');
            }
            else
                
$this->error('Devi specificare un template-file!');
        }
        

    
//------------------------------------------------------------------------
    // newtag($n, $v) -> nome(strng), valore
    //------------------------------------------------------------------------        
        
public function newtag($n$v)
        {
            if (
is_string($n) && is_array($v))
            {
                
// quello che si cerca di immettere è un loop
                
$this->setloop($n$v);
            }
            else if (!empty(
$n) && !empty($v) && is_string($v))
            {
                
// è stato immesso un solo tag
                
$this->__tags[$n] = $v;
            }
            else
                
$this->errore('Il formato in cui hai inserito il Tag non è valido!');
        }
        

    
//------------------------------------------------------------------------
    // setloop($n, $a) -> nome(string), array(array)
    //------------------------------------------------------------------------        
        
private function setloop($n$a)
        {
            foreach (
$a as $nome => $valore)
            {                
                if (
is_array($valore))
                {    
                    
$this->setloop($nome$valore);
                }
                
$this->__tags[$nome] = $valore;
            }
        }
    }
// fine classe. 
mi piacerebbe poter scrivere cose simili:

Codice PHP:
[b]{titolo}[/b]
<
table>
    {
loop righe}
    <
tr>
        <
td>{righe.chatName}</td>
    </
tr>
    <
tr>
        <
td>
        {
loop righe.lastmex}
            <
div>
            {
colonne.contatore} - [url="{colonne.url}"]{colonne.user}[/url]

            </
div>
        {/
loop}
        </
td>
    </
tr>
    <
tr>
        <
td>utenti online : {righe.online}</td>
    </
tr>
    {/
loop}
</
table
con un array di questo tipo :


Codice PHP:
array(
    
'titolo' => 'tabella Chat',
    
'righe' => array(
        [
0] => array(
            
'chatName' => 'chat1',
            
'lastmex' => array(
                [
0] => array( 
                    
'user' => 'nome1',
                    
'url' => 'http://...'
                
),
                [
1] => array( 
                    
'user' => 'nome2',
                    
'url' => 'http://...'
                
),
                [
2] => array( 
                    
'user' => 'nome3',
                    
'url' => 'http://...'
                
)
            ),
            
'online' => '12'
        
),
        [
1] => array(
            
'chatName' => 'chat1',
            
'lastmex' => array(
                [
0] => array( 
                    
'user' => 'nome1',
                    
'url' => 'http://...'
                
),
                [
1] => array( 
                    
'user' => 'nome2',
                    
'url' => 'http://...'
                
),
                [
2] => array( 
                    
'user' => 'nome3',
                    
'url' => 'http://...'
                
)
            ),
            
'online' => '12'
        
)