日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > windows >内容正文

windows

有用的函数-系统采集(一)

發(fā)布時(shí)間:2023/12/16 windows 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 有用的函数-系统采集(一) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.采集表格中的內(nèi)容為數(shù)組

?

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); //OSPHP.com.CN

? ?? ???foreach ($table as $key=>$tr) {

? ?? ?? ?? ?? ? $td = explode('{td}', $tr);

? ?? ?? ?? ?? ? array_pop($td);

? ?? ?? ?? ?$td_array[] = $td;

? ?? ???}

? ?? ???return $td_array;

}

2.取得某行代碼中間的字符串

?

/**

+----------------------------------------------------------

* 取得某行代碼之間的字符串

+----------------------------------------------------------

* 例: echo get_innerhtml("<tr><td height=20>something</td></tr>", "td");? ?//will print "something".

+----------------------------------------------------------

*/

function get_innerhtml($html,$label) {

? ? $result_arr = preg_split("/<\/".$label.">/i",$html);

? ? $pattern = "/<".$label.".*?>/i";

? ? for ($i = 0; $i < count($result_arr); $i++) {

? ?? ???list($left, $right) = preg_split($pattern,$result_arr[$i],2);

? ?? ???$result_arr[$i] = $right;

? ? }

? ? return $result_arr;

}

復(fù)制代碼

3.獲取Input的HTML代碼中的Value值

?

//獲取Input的HTML代碼中的Value值

function get_input_value($input) {

?? $pos = stripos($input, "value=") + 6;

? ? if ($pos !== false) {

? ?? ???$input = substr($input, $pos);

? ?? ???if (substr($input, 0, 1) == "\"")

? ?? ?? ?? ?return substr($input, 1, strpos($input, "\"", 1) - 1);

? ?? ???else

??? ?? ?? ?return substr($input, 0, strpos($input, " ") - 1);

? ? }

? ? return false;

}

4.獲取字符串$str中,字符串$a與字符串$b之間的字符串

//獲取字符串$str中,字符串$a與字符串$b之間的字符串

function getcontentbetween($a, $b, $str) {

? ? if ($str!=="" && $a!=="" && $b!=="") {

? ?? ???$start = strpos($str, $a) + strlen($a);

? ?? ???return substr($str, $start, strpos($str, $b, $start + 1) - $start);

? ? }

? ? return false;

}

5.<br>變成回車

function br2nl($text)

{

? ?return??trim(preg_replace('/<br\s*/?'.'>/i', '', $text));

}

6.換行奕成<p></p>

function nl2p($text)

{

return str_replace(array("\r\n\r\n","\r\n","\r","\n"),"</p><p>",$text);

}

7.獲得當(dāng)前腳本網(wǎng)址

function get_php_url(){?

? ?? ???if(!empty($_SERVER["REQUEST_URI"])){?

? ?? ?? ?? ?? ? $scriptName = $_SERVER["REQUEST_URI"];?

? ?? ?? ?? ?? ? $nowurl = $scriptName;?

? ?? ???}else{?

? ?? ?? ?? ?? ? $scriptName = $_SERVER["HP_SELF"];?

? ?? ?? ?? ?? ? if(empty($_SERVER["QUERY_STRING"])) $nowurl = $scriptName;?

? ?? ?? ?? ?? ? else $nowurl = $scriptName."?".$_SERVER["QUERY_STRING"];?

? ?? ???}?

? ?? ???return $nowurl;?

}

轉(zhuǎn)載于:https://www.cnblogs.com/hylaz/archive/2012/12/24/2830734.html

總結(jié)

以上是生活随笔為你收集整理的有用的函数-系统采集(一)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。