remove special tag with content

Discussion in 'PHP' started by playwright, Jun 4, 2010.

  1. #1
    I want to remove a div tag with all its content..so far i' m able to remove tags that don't contain any other tags inside..e.g <b>bla bla bla </b>..However the div tag i want to remove is like <div class="" style=""><tag>bla bla...<other tag/>....</tag></div>..any ideas??
     
    playwright, Jun 4, 2010 IP
  2. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Use the strip_tags function;

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

    E.G


    <?php
    
    $tagged = '<div class="" style=""><tag>bla bla...<other tag/>abcd</tag></div>';
    $stripped = strip_tags($tagged);
    
    print $stripped;
    ?>
    PHP:

    Output: bla bla...abcd
     
    lukeg32, Jun 4, 2010 IP