HTML tags in a php text var are getting displayed literally

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
intellivision
Forum Commoner
Posts: 83
Joined: Mon Aug 22, 2005 1:25 am
Location: Orbit

HTML tags in a php text var are getting displayed literally

Post by intellivision »

Code: Select all

preg_replace( '(<p>|</p>)', '', $row->post_text);
That is taking post_text and removing the paragraph tags, obviously. Reson: the tags are displayed literally as
<p> and </p> when the result is spit back out and displayed in my forum.

How can I have nice paragraphs in the text that's spit back out without having the literal paragraph tags?

I tried

Code: Select all

preg_replace( '(<p>|</p>)', '\n', $row->post_text);
but that spits out a literal "\n" between paragraphs. Ack.

I'm getting literalled to death here.

Here's the whole bit

Code: Select all

function bb_quote_message() {
	global $bbdb, $topic;
	$post_id = (int)$_GET['quote']; 
	$the_author = $_GET['author'];
	$the_author = str_replace('!~', ' ', $the_author);
	if ($post_id) {
		$row = $bbdb->get_row("SELECT * FROM $bbdb->posts WHERE post_id={$post_id} AND topic_id={$topic->topic_id} AND post_status=0");
		$row->post_text = rtrim(preg_replace( '(<p>|</p>)', '', $row->post_text));
		if ($row) echo ($the_author.' said:<br />'.htmlentities('<blockquote>'.$row->post_text.'</blockquote>', ENT_COMPAT, 'UTF-8')."\n");
	}
}
Post Reply