天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

[PHP]實用函數(shù)3

//獲得當(dāng)前的腳本網(wǎng)址
復(fù)制代碼 代碼如下:
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ù)字
復(fù)制代碼 代碼如下:
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)記
復(fù)制代碼 代碼如下:
function Text2Html($txt){ 
        $txt = str_replace("  "," ",$txt); 
        $txt = str_replace("<","<",$txt); 
        $txt = str_replace(">",">",$txt); 
        $txt = preg_replace("/[/r/n]{1,}/isU"," 
/r/n",$txt); 
        return $txt; 


//清除HTML標(biāo)記 
復(fù)制代碼 代碼如下:

function ClearHtml($str){ 
        $str = str_replace('<','<',$str); 
        $str = str_replace('>','>',$str); 
        return $str; 


//相對路徑轉(zhuǎn)化成絕對路徑
復(fù)制代碼 代碼如下:

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("http:///.*/", "", $server_url);  

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

    if (isset($protocol[0])) {  
        $new_content = preg_replace('/href="http:///', 'href="'.$protocol[0].$server_url.'/', $content);  
        $new_content = preg_replace('/src="http:///', 'src="'.$protocol[0].$server_url.'/', $new_content);  
    } else {  
        $new_content = $content;  
    }  
    return $new_content;  
}  

//取得所有鏈接
復(fù)制代碼 代碼如下:
function get_all_url($code){  
        preg_match_all('/<a/s+href=["|/']?([^>"/' ]+)["|/']?/s*[^>]*>([^>]+)<//a>/i',$code,$arr);  
        return array('name'=>$arr[2],'url'=>$arr[1]);  


//HTML表格的每行轉(zhuǎn)為CSV格式數(shù)組 
復(fù)制代碼 代碼如下:
function get_tr_array($table) { 
        $table = preg_replace("'<td[^>]*?>'si",'"',$table); 
        $table = str_replace("</td>",'",',$table); 
        $table = str_replace("</tr>","{tr}",$table); 
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("'([/r/n])[/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ù)
復(fù)制代碼 代碼如下:
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("'([/r/n])[/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ù)
復(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]; 
}

php技術(shù)[PHP]實用函數(shù)3,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 干极品美女 | 色婷婷国产精品视频一区二区三区 | 奇米精品一区二区三区在线观看 | 9久久99久久久精品齐齐综合色圆 | 伊人狠狠丁香婷婷综合尤物 | 亚洲视频在线观看地址 | 国产69精品久久久久妇女 | 美女叉腿掰阴大胆艺术照 | 97人人超碰国产精品最新蜜芽 | 国产中文视频 | 依人在线观看 | 撅高 自己扒开 调教 | 成人区精品一区二区不卡AV免费 | 性春院| 91精品国产品国语在线不卡 | 男欢女爱免费视频 | 全彩黄漫火影忍者纲手无遮挡 | 青青涩射射 | 久久re这里精品23 | 色婷婷五月综合中文字幕 | 精品久久久久中文字幕加勒比东京热 | 古风一女N男到处做高H | 国产精品人妻无码久久久蜜桃臀 | 综合网伊人 | 国产欧美日韩视频怡春院 | 恋老视频 国产国佬 | 日本阿v直播在线 | 忘忧草在线影院www日本 | 交换年轻夫妇HD中文字幕 | 孕妇bbwbbwbbwbbw超清 | 人人草人人草 | 免费观看桶机十分钟 | 我的年轻漂亮继坶三级 | 2020年国产理论 | 天天躁日日躁狠狠躁午夜剧场 | 亚洲人精品午夜射精日韩 | 成人18视频在线观看 | 精品无人区麻豆乱码1区2 | 亚洲精品视频免费在线观看 | 女教师跟黑人男朋友激情过后 | 奶水四溅54p |