Well i want to strip only the <a> tags from html code and keep ALL other tags

Is there a different way to do that except just listing all possible other tags as second argument?

If there is no other way, where i can find list of all html tags 🙂

    Only allowing <a></a>? You may have to use preg_match to find those that aren't <a.?>.?<\/a> tags 😉

    i.e.:

    $string = '<a href="www.mysite.com">A Link</a><b>Some bold text</b><p>A Paragraph</p><a>A blank Link</a>';
    
    $pattern = '#\<a.*?\>(.*?)\<\/a\>#si';
    $replace = '$1';
    echo $string.'<br />
    ';
    echo preg_replace($pattern, $replace, $string);

    That produces:

    <a href="www.mysite.com">A Link</a><b>Some bold text</b><p>A Paragraph</p><a>A blank Link</a><br />
    A Link<b>Some bold text</b><p>A Paragraph</p>A blank Link

      thanks for the code dude
      but i guess i haven't express myself clear enough

      I want to remove all kinds of links and leave all the other tags

        $newString = preg_replace('#</?a(\s[^>]*)?>#i', '', $string);
        
          NogDog wrote:
          $newString = preg_replace('#</?a(\s[^>]*)?>#i', '', $string);
          

          thanks dude! Works perfect! 🙂

            Write a Reply...