$message = "<a href=\"http://www.stackoverflow.com\" target=\"new\">My link</a>";
function unclick ($message) {
$message = preg_replace("#\<a.+href\=[\"|\'](.+)[\"|\'].*\>.*\<\/a\>#U","$1",$message);
$message = str_replace("mailto:","",$message);
return $message;
}
當鏈接看起來像這樣這隻適用:
http://stackoverflow.com/
不幸的是,它不適合長期環節的工作:
http://stackoverflow.com/questions/ask
需要一種方法來從所有鏈接中刪除html標籤。謝謝。
爲我工作:) – Tapos 2011-06-02 16:42:02
是您希望輸出'「我的鏈接」'或'的「http://計算器.com/questions/ask「'? – jball 2011-06-02 16:49:17
這就是['strip_tags()'](http://php.net/strip_tags)的用途。 – ceejayoz 2011-06-02 16:34:51