Get all link content and addresses Function getAllURL ($ code ){ Preg_match_all ('/"'] +) [" | ']? S * [^>] *> ([^>] +)/I ', $ code, $ arr ); Return array ('name' => $ arr [2], 'URL' => $ arr [1]); } Get all image addresses Function getImgSrc ($ code ){ $ Reg = "/] * src =" (http ://(. + )/(. + ). (jpg | gif | bmp | bnp | png) "/isU "; Preg_match_all ($ reg, $ code, $ img_array, PREG_PATTERN_ORDER ); Return $ img_array [1]; } Current script URL Function getSelfURL (){ 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; } Convert full-angle numbers into half-angle numbers 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; } Remove HTML tags Function text2Html ($ txt ){ $ Txt = str_replace ("", "", $ txt ); $ Txt = str_replace ("<", "<", $ txt ); $ Txt = str_replace (">", ">", $ txt ); $ Txt = preg_replace ("/[rn] {1,}/isU "," Rn ", $ txt ); Return $ txt; } Clear HTML tags Function clearHtml ($ str ){ $ Str = str_replace ('<', '<', $ str ); $ Str = str_replace ('>', '>', $ str ); Return $ str; } Convert relative paths to absolute paths Function relative2Absolute ($ 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 = "//', '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; } Obtains the content in the specified tag. Function getTagData ($ str, $ start, $ end ){ If ($ start = ''| $ end = ''){ Return; } $ Str = explode ($ start, $ str ); $ Str = explode ($ end, $ str [1]); Return $ str [0]; } Convert each line of an HTML table to an array in CSV format Function getTrArray ($ table ){ $ Table = preg_replace ("' ] *?> 'Si ", '"', $ table ); $ Table = str_replace (" | ", '",', $ Table );$ Table = str_replace ("
"," {Tr} ", $ table );// Remove the HTML tag$ Table = preg_replace ("'<[/!] *? [^ <>] *?> 'Si "," ", $ table );// Remove the white space characters$ Table = preg_replace ("'([rn]) [s] +'", "", $ table );$ Table = str_replace ("", "", $ table );$ Table = str_replace ("", "", $ table );$ Table = explode (", {tr}", $ table );Array_pop ($ table );Return $ table;}