...

View Full Version : Function to strip tags?



gorilla1
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).

G

Celtboy
01-20-2004, 07:52 AM
step 1:
http://us4.php.net/stripslashes

Spookster
01-20-2004, 03:08 PM
I think what Celtboy meant was this function

http://us3.php.net/manual/en/function.strip-tags.php

3d.magic
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
.e.g
</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?

trib4lmaniac
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;
?>

trib4lmaniac
06-28-2004, 07:40 AM
Forgot a modifier, need "msi" (multiline, dot counts as newliine and case-insensitive.)

3d.magic
06-28-2004, 01:11 PM
thanks trib4lmaniac.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum