I have integrated the forum on my website, all works well.
But I use a function to truncate the message and if a tag (<b> <em> etc..) is opened before the function truncates the message, it stays open.
How to close automatically the opened tags?
here is a picture :
and the function to trunc the message :
Code: Select all
function tronquer_texte( $texte, $nbchar ) {
return (strlen($texte) > $nbchar ? substr(substr($texte,0,$nbchar),0,
strrpos(substr($texte,0,$nbchar)," "))." (...)" : $texte);
}
Code: Select all
$text = preg_replace($patterns, $replace, $row[9]);
$text = str_replace($amodif, $modif, $text);
$text = nl2br($text);
echo tronquer_texte($text, 300);
Cya !
EDIT : I have found a "temp solution" by replacing a part of the function (strrpos(substr($texte,0,$nbchar)," "))."</b></i></u> (...)" : $texte);)