Problem with tags when integrating messages on my website.

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
askafreedom
Registered User
Posts: 1
Joined: Sun Jan 07, 2018 10:17 pm

Problem with tags when integrating messages on my website.

Post by askafreedom »

Hello world !!!
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 : Image

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);
	}
with the call function :

Code: Select all

					$text = preg_replace($patterns, $replace, $row[9]);
					$text = str_replace($amodif, $modif, $text);
					$text = nl2br($text);
                   			 echo tronquer_texte($text, 300);
thank you for your attention! :)
Cya !

EDIT : I have found a "temp solution" by replacing a part of the function (strrpos(substr($texte,0,$nbchar)," "))."</b></i></u> (...)" : $texte);)
Post Reply

Return to “phpBB Custom Coding”