您的位置:手机购彩平台 > 手机购彩平台-编程 > PHP 采集程序中常用的函数_php技巧_脚本之家

PHP 采集程序中常用的函数_php技巧_脚本之家

2020-01-16 04:34

复制代码 代码如下://取伏贴前的台本网站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; } //把全角数字转为半角数字 function GetAlabNum { $nums = array(”0”,”1”,”2”,”3”,”4”,”5”,”6”,”7”,”8”,”9”卡塔尔; $fnums = “0123456789″; for $fnum = str_replace($nums[$i],$fnums[$i],$fnum); $fnum = ereg_replace(”[^0-9.]|^0{1,}”,””,$fnum); if $fnum=0; return $fnum; } //去除HTML标记 function Text2Html { $txt = str_replace; $txt = str_replace; $txt = str_replace; $txt = preg_replace(”/[rn]{1,}/isU”,”
rn”,$txt); return $txt; } //清除HTML标记 function ClearHtml { $str = str_replace; $str = str_replace; return $str; } //相对路线转变成相对路线 function relative_to_absolute { preg_match:///', $feed_url, $protocol); $server_url = preg_replace(”/:///”, “”, $feed_url); $server_url = preg_replace(”//.*/”, “”, $server_url); if { return $content; } if { $new_content = preg_replace('/href=”//', ‘href=”‘.$protocol[0].$server_url.'/', $content); $new_content = preg_replace('/src=”//', 'src=”‘.$protocol[0].$server_url.'/', $new_content); } else { $new_content = $content; } return $new_content; } //得到全体链接 function get_all_url{ preg_match_all('/]*>/i',$code,$arr); return array('name'=>$arr[2],'url'=>$arr[1]卡塔尔(قطر‎; } //获取内定标志中的内容 function get_tag_data { if ( $start == ” || $end == ” ) { return; } $str = explode; $str = explode; return $str[0]; } //HTML表格的每行转为CSV格式数组 function get_tr_array { $table = preg_replace(”‘

]*?>'si”,'”‘,$table); $table = str_replace; $table = str_replace(””,”{tr}”,$table); //去掉 HTML 标记 $table = preg_replace(”‘]*?>'si”,””,$table卡塔尔(قطر‎; //去掉空白字符 $table = preg_replace[s]+'”,””,$table); $table = str_replace; $table = str_replace; $table = explode; array_pop; return $table; } //将HTML表格的每行每列转为数组,搜集表格数据 function get_td_array { $table = preg_replace(”‘

]*?>'si”,””,$table); $table = preg_replace(”‘

]*?>'si”,””,$table); $table = preg_replace(”‘

]*?>'si”,””,$table); $table = str_replace(”

”,”{tr}”,$table); $table = str_replace(””,”{td}”,$table); //去掉 HTML 标记 $table = preg_replace(”‘]*?>'si”,””,$table卡塔尔国; //去掉空白字符 $table = preg_replace[s]+'”,””,$table); $table = str_replace; $table = str_replace; $table = explode; array_pop; foreach { $td = explode; array_pop; $td_array[] = $td; } return $td_array; } //重临字符串中的全体单词 $distinct=true 去除重复 function split_en_str { preg_match_all/',$str,$match); if { $match[1] = array_unique; } sort; return $match[1]; }

本文由手机购彩平台发布于手机购彩平台-编程,转载请注明出处:PHP 采集程序中常用的函数_php技巧_脚本之家

关键词: