?
Solved

Stripping <p> taags using php

Posted on 2007-10-04
1
Medium Priority
?
250 Views
Last Modified: 2008-02-05
I have this output as a php string

<strong>3rd Oct </strong>European Duathlon Championships <p>The European Duathlon Championships will be televised on<a href="news_article.php?id=242" class="news_link">..read more</a>

I need to strip all the instances of <p> out of it.

Any ideas how. I have tried strip_tags and str_replace but cannot seem to get it working
0
Comment
Question by:roscoeh23
1 Comment
 
LVL 4

Accepted Solution

by:
Binkers earned 2000 total points
ID: 20015687
I would do it like this.

$input_string = '<strong>3rd Oct </strong>European Duathlon Championships <p>The European Duathlon Championships will be televised on<a href="news_article.php?id=242" class="news_link">..read more</a>';

echo str_replace('</p>', '', str_replace('<p>', '', $input_string));

Strip tags tags the opposite approach and allows you to feed in which tags you will allow rather than the ones you want to remove.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question