PHP中转换twitter链接

function twitterify($ret) {
$ret = preg_replace("#(^|[n ])([w]+?://[w]+[^ "nrt< ]*)#", "1<a href="2" target="_blank">2</a>", $ret);
$ret = preg_replace("#(^|[n ])((www|ftp).[^ "tnr< ]*)#", "1<a href="http://2" target="_blank">2</a>", $ret);
$ret = preg_replace("/@(w+)/", "<a href="http://www.twitter.com/1" target="_blank">@1</a>", $ret);
$ret = preg_replace("/#(w+)/", "<a href="http://twitter.com/search?q=1" target="_blank">#1</a>", $ret);
return $ret;
}

Published by

@XiaoKyun

双鱼男,过分热心的好人。