GitsD
GitsD

Reputation: 668

how to Remove <a> and all other html tags from tha output string not at the time of input string in PHP?

I am wondering to know how it can be possible to remove the tags from output string in PHP. At the time of input It can be removed by strip_tags() that I know but From already generated output where html tags appeared, How it can be removed ?

For example :

<p>Test paragraph.</p> <a href="#fragment">Other text</a>

Screenshot:

enter image description here

I have pointed what i am getting from database. Its like static text.

This is the output string appearing in my blog description. I want to remove html tags from the string. How can i be removed.

Sorry For poor english Any Help will be greatly appreciated.

ThankYou

Upvotes: 0

Views: 597

Answers (1)

MaxVT
MaxVT

Reputation: 13234

If your blog is statically generated, you can run strip_tags() on any file in the filesystem, but the result is not likely to be very pleasant to read:

$str = file_get_contents($filename);
$text_only = strip_tags($str);
file_put_contents($new_filename, $text_only);

Upvotes: 1

Related Questions