Bene o male il problema dei tag l'ho risolto.

Senza che apro un'altro topic:
sto scrivendo una "mini" classe per i template, solo che la regex non funziona molta bene in quanto estrae più dati del necessario. Posto il tutto.


template.php
Codice PHP:
<?php

class tpl
{
    function 
tpl$p )
    {
        
$this->page file_get_contents"tpl/$p.tpl" );
        
$this->page $this->compile$this->page );
    }
    
    function 
compile$p )
    {
        
$regex  "/";
        
$regex .= "(<#\\s*foreach\\s*direct\\s*=\\s*'(.*)'\\s*#>)";
        
$regex .= "/is";
        
        
$return preg_split$regex $p , -PREG_SPLIT_DELIM_CAPTURE PREG_SPLIT_NO_EMPTY );
        
        
$code "";
        
        while ( 
$html array_shift$return ) )
        {
            
            if ( 
preg_match"/(<#\\s*foreach\\s*direct\\s*=\\s*'(.*?)'\\s*#>)/is" $html $r ) )
            {
                
$code .= "\n <?php foreach ( /**/ ) { \n";
            }
            
            else
            {
                
$code .= $html;
            }
        }
        
        echo 
$code;
    }
}

$a = new tpl"lol" );

?>
tpl/lol.tpl
codice:
1<#foreach direct='asd'#>
Output:
codice:
1
 <?php foreach (  ) { 
asd
Perchè mi stampa anche asd ? Come evito che stampi la variabile all'interno di direct='' nell'output?