how to parse HTML tags to plain text?I want to achive something like facebook or twitter

后端 未结 1 595
梦如初夏
梦如初夏 2021-01-17 01:09

For example: I have this string

@[1234:peterwateber] hello 
hi!
http://stackoverflow.com

I want t

相关标签:
1条回答
  • 2021-01-17 01:43

    I'm not entirly sure if there is a specific function just for that but what you can do is this: in example of the link (a href)

    $raw = "@[1234:peterwateber]"
    $thingtoreplace = ("@[");
    $firstpass = str_replace($thingtoreplace, "<a href='", $raw);
    $raw2 = $firstpass
    $thingtoreplace = (":");
    $secondpass = str_replace($thingtoreplace, "'>", $raw1);
    $raw3 = $second
    $thingtoreplace = ("]");
    $secondpass = str_replace($thingtoreplace, "'</a>", $raw3);
    

    I know it seems tedious but it should do the trick. If its not helpful then please dont rate me down... I spent time on this

    0 讨论(0)
提交回复
热议问题