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
step 1:

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.
Any clues?

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);
echo $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
thanks trib4lmaniac.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum