linked text to normal [function?]

Discussion in 'PHP' started by ~MasteR, Dec 10, 2007.

  1. #1
    I have problem. I want to something like that;

    <a href="abc.com">abc</a>

    to convert this;

    abc



    linked text to unlinked text.

    something like that, so can somebody help to me about this topic? Who can write a function for me?

    thanks all.
     
    ~MasteR, Dec 10, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    $text = preg_replace('~<a[^>]+>(.*?)</a>~si', '$1', $text);
    
    PHP:
     
    nico_swd, Dec 10, 2007 IP
  3. jmiil

    jmiil Member

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    strip_tags()
    Code (markup):
     
    jmiil, Dec 10, 2007 IP
    hogan_h likes this.
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    strip_tags() removes ALL tags, and not only the <a> tags.
     
    nico_swd, Dec 10, 2007 IP