php中將網址轉換為超鏈接的函數
更新時間:2011年09月02日 15:27:30 作者:
php中將網址轉換為超鏈接的函數,需要的朋友可以參考下。
復制代碼 代碼如下:
function showtext($text){
$search = array('|(http://[^ ]+)|', '|(https://[^ ]+)|', '|(www.[^ ]+)|');
$replace = array('<a href="$1" target="_blank">$1</a>', '<a href="$1" target="_blank">$1</a>', '<a href="http://$1" target="_blank">$1</a>');
$text = preg_replace($search, $replace, $text);
return $text;
}
相關文章
SESSION信息保存在哪個文件目錄下以及能夠用來保存什么類型的數據
session默認是保存到c:\windows\temp目錄下,但是通過修改php.ini中的session.save_path值可以改變session的保存路徑2012-06-06
PHP中數字檢測is_numeric與ctype_digit的區(qū)別介紹
PHP中的兩個函數is_numeric和ctype_digit都是檢測字符串是否是數字,但也存在一點區(qū)別2012-10-10

