PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Dec 10, 2018 12:25 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Oct 29, 2007 7:40 pm 
Offline
Forum Commoner

Joined: Mon Aug 22, 2005 1:25 am
Posts: 83
Location: Orbit
feyd | Please use
Syntax: [ Download ] [ Hide ]
,
[syntax=php]and
Syntax: [ Download ] [ Hide ]
  1. tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too. 
Syntax: [ Download ] [ Hide ]
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

Syntax: [ Download ] [ Hide ]
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
Syntax: [ Download ] [ Hide ]
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");

        }

}



feyd | Please use
Syntax: [ Download ] [ Hide ]
,
[syntax=php]and
Syntax: [ Download ] [ Hide ]
  1. tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too. 


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 30, 2007 3:25 am 
Offline
Tranquility In Moderation
User avatar

Joined: Sun Feb 06, 2005 8:18 pm
Posts: 5001
Location: Indiana
Maybe you're looking for nl2br()?

_________________
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 30, 2007 1:11 pm 
Offline
Forum Commoner

Joined: Mon Aug 22, 2005 1:25 am
Posts: 83
Location: Orbit
scottayy, thanks that did it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group