View Full Version : Function to strip tags?
01-20-2004, 04:15 AM
Is there a php function that will take a string and remove all content from it that is within html tags (including the tags themselves).
01-20-2004, 07:52 AM
01-20-2004, 03:08 PM
I think what Celtboy meant was this function
06-27-2004, 02:17 PM
If you take some data out of a HTML table and put it in a string, the data in the string is seperated by HTML tags.
On the HTML page the data appears with spaces between the data, but when stip_tags is used all the data ends up in one long continous string, so instead of removing the tags , I want to replace groups of HTML tags
</span></td><td align="left"><span class="style5">
with one blank space, so that the data will be distinct and readable in the created string.
06-27-2004, 07:20 PM
Well you could use regexps to replace anything between <>'s with a space. multiple tags would result in multiple spaces, but excess whitespace is disregarded in HTML so...
$htmlstr='Whatever <b>html<i>code</i></b> you want <span id="myspan">in here</span>';
preg_replace('|<.*?>|ms', ' ', $htmlstr);
06-28-2004, 07:40 AM
Forgot a modifier, need "msi" (multiline, dot counts as newliine and case-insensitive.)
06-28-2004, 01:11 PM
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.