Reputation: 668
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:
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
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