alla seconda e terza domanda sono riuscito a rispondermi...
ho trovato sempre su php.net (http://it.php.net/preg_replace) quest'utilissimo esempio
scusate...ma il codice viene modificato dal forumCodice PHP:<?php
function convert_bb($text) {
$temp = split("\n", $text);
$bb_code[0] = '/(\[t\])(.*)(\[\/t\])/'; // Notice how you have to escape each regex identifier so that it will match literally.
$bb_replace[0] = '<span class="term">${2}</span>';
$temp2 = preg_replace($bb_code, $bb_replace, $temp);
$temp2 = implode("\n", $temp2);
return $temp2;
}
function convert_html($text) {
$temp = split("\n", $text);
$html_code[0] = '/(<span class="term">)(.*)(<\/span>)/';
$html_replace[0] = '[t]${2}[/t]';
$temp2 = preg_replace($html_code, $html_replace, $temp);
$temp2 = implode("\n", $temp2);
return $temp2;
}
?>
cmq nn capisco perchè effettui lo split su \n, a me funziona anche anche senza lo split nonostante il testo sia su più righe...
però il mio primo dubbio rimane... se un utente inserisse un tag in maiuscolo... non verrebbe riconosciuto dalla funzione...
c'è qualche modo per risolvere?
ciauz e grazie

Rispondi quotando