Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Function to strip tags?

    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

  • #2
    Regular Coder
    Join Date
    May 2002
    Location
    Virginia, USA
    Posts
    621
    Thanks
    0
    Thanked 6 Times in 6 Posts

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    I think what Celtboy meant was this function

    http://us3.php.net/manual/en/function.strip-tags.php
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #4
    New Coder
    Join Date
    Jun 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Code:
    </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?

  • #5
    Regular Coder trib4lmaniac's Avatar
    Join Date
    Feb 2004
    Location
    Cornwall, UK
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...
    PHP Code:
    <?
    $htmlstr
    ='Whatever <b>html<i>code</i></b> you want <span id="myspan">in here</span>';
    preg_replace('|<.*?>|ms'' '$htmlstr);
    echo 
    $htmlstr;
    ?>

  • #6
    Regular Coder trib4lmaniac's Avatar
    Join Date
    Feb 2004
    Location
    Cornwall, UK
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Forgot a modifier, need "msi" (multiline, dot counts as newliine and case-insensitive.)
    Last edited by trib4lmaniac; 06-28-2004 at 07:18 PM.

  • #7
    New Coder
    Join Date
    Jun 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks trib4lmaniac.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •