1. il file html devi rinominarlo con .php, così il codice verrà interpretato e reso a schermo
2. con uno switch risolvi facilmente, sempre che i campi non siano troppi...

Codice PHP:

<?php  
function convertIntoTab($filename,$seperator,$lineseperator) { 
    
// queste due variabili non servono
    
$row=1;
    
$count=0

    if ((
$handle fopen($filename"r")) !== FALSE) { 
        while ((
$data fgets($handle)) !== FALSE) { 
                echo 
"<table>\n";                 
                
$str=explode($seperator,$data); 
                foreach(
$str as $k => $str1) { 
                    
// sulla base della chiave, definisci lo stile
                    
switch ($k) {
                          case 
1:
                            
$style 'class="TITOLO"';
                            break;
                        case 
2
                            
$style 'class="QUANDO"';
                            break;    
                        default: 
                            
$style "";
                            break;
                    }
                    
                    if (
$k != 0) { 
                        echo 
"<tr>\n";
                        
// questo toglie il "+" dalla coda dell'ultima stringa
                        
if (substr(trim($str1), -1) === $lineseperator) {
                            
$str1 substr(trim($str1), 0, -1);
                        }
                        
// nel td aggiungi lo stile
                        
echo "<td $style>\n".$str1."\n</td>\n";  
                        echo 
"</tr>\n";  
                    } 
                } 
                echo 
"</table>\n";     
        } 
        
fclose($handle); 
    } 

print 
convertIntoTab('test.txt',"#","+"); 

?>