Eliminate <p> tags in my echo command?

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
VKX
Forum Commoner
Posts: 41
Joined: Mon Oct 03, 2005 1:43 pm

Eliminate <p> tags in my echo command?

Post by VKX »

How can I eliminate <p> tags in my return? Here's the code, followed by the output, followed by what I would like the output to look like.

Code: Select all

while ($i < 1): 
    $date = mysql_result($rs,$i,"date");
    $subject = mysql_result($rs,$i,"subject");
    $text = mysql_result($rs,$i,"text");
	preg_match('#^\s*(.{500,}?)\s+.*$#s', $text, $return); 
	echo "<p>" . $return[1] . "...</p>";
    $i++; 
    endwhile;
Current Output:

We're got a brand new guest skin (SUGARCULT!) by a brand new additon to our team, Julie Morris!

There's a lot of buzz regarding AwesomeStart Version 2.0 flying around the net, so it would probably be a good idea to clear some of this up. We have set a temporary online launch date of 10.22.2005 (next Saturday). This is the FIRST TIME we've set a launch date, so anything else you've heard is false. We will not be charging any kind of...

Desired Output:

We're got a brand new guest skin (SUGARCULT!) by a brand new additon to our team, Julie Morris! There's a lot of buzz regarding AwesomeStart Version 2.0 flying around the net, so it would probably be a good idea to clear some of this up. We have set a temporary online launch date of 10.22.2005 (next Saturday). This is the FIRST TIME we've set a launch date, so anything else you've heard is false. We will not be charging any kind of...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

strip_tags() ?
VKX
Forum Commoner
Posts: 41
Joined: Mon Oct 03, 2005 1:43 pm

Post by VKX »

I dont' want to strip all the tags though, just the <p> ones. I have a href tags I want to keep in.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

str_replace() then, or use strip_tags() with the second argument.
Post Reply