Strip non-tags

Discussion in 'PHP' started by yleiko, Aug 17, 2008.

  1. #1
    Hi,
    Is there a quick way to do the reverse of what strip_tags function does.

    I mean, strip_tags strips all tags from a string and returns the remaining, what I need is a function that strips all strings that are not tags and leave just tags.
     
    yleiko, Aug 17, 2008 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    preg_match_all('/<(.*?)>/',$html,$tags);
    foreach ($tags[0] as $x)
          print $x;
    
    PHP:
    untested, but should work.
     
    matthewrobertbell, Aug 18, 2008 IP