主要是url操作函數,可以刪除字符串的url同時也可以給字符串中的url加連接,有需要的朋友參考一下,刪除url代碼如下:
- $string = preg_replace('/b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|$!:,.;]*[A-Z0-9+&@#/%=~_|$]/i', '', $string);
將url轉換成鏈接,代碼如下:
- $url = "Jean-Baptiste Jung (http://www.49028c.com)";
- $url = preg_replace("#http://([A-z0-9./-]+)#", '<a href="http://www.111cn.net $1" style="font-size: 12px; vertical-align: baseline; background-color: transparent; margin: 0px; padding: 0px; color: #3777af; text-decoration: none; font-weight: bold">$0</a>', $url);
新聞熱點
疑難解答