午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術(shù)文章
文章詳情頁

PHP采集程序中常用的函數(shù)

瀏覽:152日期:2024-02-22 08:59:51

//獲得當(dāng)前的腳本網(wǎng)址function get_php_url(){ if(!empty($_SERVER['REQUEST_URI'])){ $scriptName = $_SERVER['REQUEST_URI']; $nowurl = $scriptName; }else{ $scriptName = $_SERVER['PHP_SELF']; if(empty($_SERVER['QUERY_STRING'])) $nowurl = $scriptName; else $nowurl = $scriptName.'?'.$_SERVER['QUERY_STRING']; } return $nowurl;}//把全角數(shù)字轉(zhuǎn)為半角數(shù)字function GetAlabNum($fnum){ $nums = array('0','1','2','3','4','5','6','7','8','9'); $fnums = '0123456789'; for($i=0;$i<=9;$i++) $fnum = str_replace($nums[$i],$fnums[$i],$fnum); $fnum = ereg_replace('[^0-9.]|^0{1,}','',$fnum); if($fnum=='') $fnum=0; return $fnum;}//去除HTML標(biāo)記function Text2Html($txt){ $txt = str_replace('; ',' ',$txt); $txt = str_replace('<','&lt;',$txt); $txt = str_replace('>','&gt;',$txt); $txt = preg_replace('/[rn]{1,}/isU','<br/>rn',$txt); return $txt;}

//清除HTML標(biāo)記function ClearHtml($str){ $str = str_replace('<','&lt;',$str); $str = str_replace('>','&gt;',$str); return $str;}//相對路徑轉(zhuǎn)化成絕對路徑function relative_to_absolute($content, $feed_url) { preg_match('/(http|https|ftp):///', $feed_url, $protocol); $server_url = preg_replace('/(http|https|ftp|news):///', '', $feed_url); $server_url = preg_replace('//.*/', '', $server_url);

if ($server_url == '') { return $content; }

if (isset($protocol[0])) { $new_content = preg_replace('/href='https://', 'href='http://www.leifengta.com.cn/bcjs/21944.html'.$protocol[0].$server_url.'/', $content); $new_content = preg_replace('/src='https://', 'src='http://www.leifengta.com.cn/bcjs/21944.html'.$protocol[0].$server_url.'/', $new_content); } else { $new_content = $content; } return $new_content;}//取得所有鏈接function get_all_url($code){ preg_match_all('/<as+href=['|']?([^>'' ]+)['|']?s*[^>]*>([^>]+)</a>/i',$code,$arr); return array('name'=>$arr[2],'url'=>$arr[1]);}

//獲取指定標(biāo)記中的內(nèi)容function get_tag_data($str, $start, $end){ if ( $start == '' || $end == '' ){ return; } $str = explode($start, $str); $str = explode($end, $str[1]); return $str[0];}//HTML表格的每行轉(zhuǎn)為CSV格式數(shù)組function get_tr_array($table) { $table = preg_replace(''<td[^>]*?>'si',''',$table); $table = str_replace('</td>','',',$table); $table = str_replace('</tr>','{tr}',$table); //去掉 HTML 標(biāo)記 $table = preg_replace(''<[/!]*?[^<>]*?>'si','',$table); //去掉空白字符 $table = preg_replace(''([rn])[s]+'','',$table); $table = str_replace(' ','',$table); $table = str_replace(' ','',$table);

$table = explode(',{tr}',$table); array_pop($table); return $table;}

//將HTML表格的每行每列轉(zhuǎn)為數(shù)組,采集表格數(shù)據(jù)function get_td_array($table) { $table = preg_replace(''<table[^>]*?>'si','',$table); $table = preg_replace(''<tr[^>]*?>'si','',$table); $table = preg_replace(''<td[^>]*?>'si','',$table); $table = str_replace('</tr>','{tr}',$table); $table = str_replace('</td>','{td}',$table); //去掉 HTML 標(biāo)記 $table = preg_replace(''<[/!]*?[^<>]*?>'si','',$table); //去掉空白字符 $table = preg_replace(''([rn])[s]+'','',$table); $table = str_replace(' ','',$table); $table = str_replace(' ','',$table); $table = explode('{tr}', $table); array_pop($table); foreach ($table as $key=>$tr) { $td = explode('{td}', $tr); array_pop($td); $td_array[] = $td; } return $td_array;}

//返回字符串中的所有單詞 $distinct=true 去除重復(fù)function split_en_str($str,$distinct=true) { preg_match_all('/([a-zA-Z]+)/',$str,$match); if ($distinct == true) { $match[1] = array_unique($match[1]); } sort($match[1]); return $match[1];}

標(biāo)簽: PHP
主站蜘蛛池模板: 国产精品96| 日韩女同强女同hd | 日韩经典一区二区三区 | 亚洲高清视频在线播放 | 成人一级片在线观看 | 日韩精品欧美激情 | 超污网站在线观看 | 韩日在线 | 国产精品69毛片高清亚洲 | 99视屏| 亚洲精品自拍偷拍 | 国产美女永久免费无遮挡 | 久久久久久一级片 | 福利在线免费视频 | 亚洲成人精选 | 99久久婷婷| 在线中文字幕一区 | 中文字幕6| 日韩精品在线观看视频 | 久久久免费看片 | 黄色亚洲| 欧美日韩国产精品一区 | 亚洲成人精品在线观看 | 伊人欧美 | 亚洲一区二区三区日韩 | 久久国产成人精品av | 黄色精品在线观看 | 午夜黄色一级片 | 亚洲最大的av网站 | 免费国产黄色 | 免费成人在线网站 | 五月综合色婷婷 | 九九精品国产 | 99re在线| av片久久 | 成年人免费看毛片 | 亚洲精品一级片 | 99r精品| 九九热久久免费视频 | 久久国产香蕉 | 天天天天操 |