国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

php把相對路徑轉(zhuǎn)換成絕對路徑方法

2024-05-04 21:47:42
字體:
供稿:網(wǎng)友

我們經(jīng)常會碰到采集內(nèi)容時,要補全地址是吧,下面我們來看看這款php把相對路徑轉(zhuǎn)換成絕對路徑方法吧,相對路徑轉(zhuǎn)化成絕對路徑實例代碼如下:

  1. function relative_to_absolute($content$feed_url) {  
  2.     preg_match('/(http|https教程|ftp):///'$feed_url$protocol);  
  3.     $server_url = preg_replace("/(http|https|ftp|news):///"""$feed_url);  
  4.     $server_url = preg_replace("//.*/"""$server_url); 
  5.  
  6.     if ($server_url == '') {  
  7.         return $content;  
  8.     } 
  9.  
  10.     if (isset($protocol[0])) {  
  11.         $new_content = preg_replace('/href="//''href="'.$protocol[0].$server_url.'/'$content);  
  12.         $new_content = preg_replace('/src="//''src="'.$protocol[0].$server_url.'/'$new_content);  
  13.     } else {  
  14.         $new_content = $content;  
  15.     }  
  16.     return $new_content;  
  17. //取得所有鏈接 
  18. function get_all_url($code){  
  19.         preg_match_all('/<as+href=["|']?([^>"' ]+)["|']?s*[^>]*>([^>]+)</a>/i',$code,$arr);  
  20.         return array('name'=>$arr[2],'url'=>$arr[1]);  

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 墨玉县| 城固县| 剑河县| 宝清县| 沁水县| 广宗县| 新兴县| 大足县| 开平市| 吴忠市| 甘泉县| 隆回县| 巴彦淖尔市| 南丰县| 依安县| 平乐县| 子洲县| 刚察县| 迁西县| 宁城县| 龙门县| 建水县| 东兰县| 眉山市| 湟源县| 大宁县| 夹江县| 锡林浩特市| 东方市| 广饶县| 奎屯市| 玛纳斯县| 宜兴市| 萝北县| 卓尼县| 垦利县| 和政县| 英超| 临清市| 白银市| 茌平县|