function description and examples common functions in PHP acquisition program common functions in PHP collection program
Gets the current script URL function get_php_url () {if (!empty ($_server["Request_uri"])) {$scriptName = $_server["R Equest_uri "]; $nowurl = $scriptName; }else{$scriptName = $_server["Php_self"]; if (Empty ($_server["query_string"])) $nowurl = $scriptName; else $nowurl = $scriptName. "?". $_server["Query_string"]; } return $nowurl; }//Convert the full-width number to half-width digital 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 tag 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; }//Clear HTML tag function clearhtml ($str) {$str = Str_replace (' < ', ' < ', $str); $str = Str_replace (' > ', ' > ', $str); return $str; }//relative path converted to absolute path 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= "\//', ' 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; }//Get all link function get_all_url ($code) {Preg_match_all ('/"\ ']+) [" |\ ']?\s*[^>]*> ([^>]+) <\/a>/i ', $co DE, $arr); Return Array (' name ' = = $arr [2], ' url ' = = $arr [1]); }//gets the contents of the specified tag function get_tag_data ($str, $start, $end) {if ($start = = "| | $end = =") {return ; } $str = Explode ($start, $str); $str = Explode ($end, $str [1]); return $str [0]; Each row of the//html table is converted to the CSV format array function Get_tr_array ($table) {$table = Preg_replace ("'
]*?> ' si ', ' "', $table); $table = Str_replace ("", ' ", ', $table); $table = Str_replace ("", "{tr}", $table); Remove HTML Markup $table = Preg_replace ("' <[\/\!") *? [^<>]*?> ' si ', ' ", $table); Remove whitespace characters $table = preg_replace ("' ([\ r \ n]) [\s]+ '", "", $table); $table = Str_replace ("", "" ", $table); $table = Str_replace ("", "" ", $table); $table = Explode (", {tr}", $table); Array_pop ($table); return $table; }//each row of the HTML table into an array, collecting the tabular data function Get_td_array ($table) {$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); Remove HTML Markup $table = Preg_replace ("' <[\/\!") *? [^<>]*?> ' si ', ' ", $table); Remove whitespace characters $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; }//returns all the words in a string $distinct =true remove duplicate function split_en_str ($str, $distinct =true) {Preg_match_all ('/([a-za-z]+)/', $st R, $match); if ($distinct = = true) {$match [1] = Array_unique ($match [1]); } sort ($match [1]); return $match [1]; } function descriptions and examples of common functions in PHP acquisition programs common functions in PHP collection programs
"," > ", $txt); $txt = Preg_replace ("/[\r\n]{1,}/isu", "\ r \ n", $txt); return $txt; }//Clear HTML tag function clearhtml ($str) {$str = Str_replace (' < ', ' < ', $str); $str = Str_replace (' > ', ' > ', $str); return $str; }//relative path converted to absolute path 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= "\//', ' 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; }//Get all link function get_all_url ($code) {Preg_match_all ('/"\ ']+) [" |\ ']?\s*[^>]*> ([^>]+) <\/a>/i ', $code, $arr); Return Array (' name ' = = $arr [2], ' url ' = = $arr [1]); }//gets the contents of the specified tag function get_tag_data ($str, $start, $end) {if ($start = = "| | $end = =") {return; } $str = Explode ($start, $str); $str = Explode ($end, $str [1]); return $str [0]; Each row of the//html table is converted to the CSV format array function Get_tr_array ($table) {$table = Preg_replace ("'
]*?> ' si ', ' "', $table); $table = Str_replace ("", ' ", ', $table); $table = Str_replace ("", "{tr}", $table); Remove HTML Markup $table = Preg_replace ("' <[\/\!") *? [^<>]*?> ' si ', ' ", $table); Remove whitespace characters $table = preg_replace ("' ([\ r \ n]) [\s]+ '", "", $table); $table = Str_replace ("", "" ", $table); $table = Str_replace ("", "" ", $table); $table = Explode (", {tr}", $table); Array_pop ($table); return $table; }//each row of the HTML table into an array, collecting the tabular data function Get_td_array ($table) {$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); Remove HTML Markup $table = Preg_replace ("' <[\/\!") *? [^<>]*?> ' si ', ' ", $table); Remove whitespace characters $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; }//returns all the words in a string $distinct =true remove duplicate 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]; }
http://www.bkjia.com/PHPjc/446999.html www.bkjia.com true http://www.bkjia.com/PHPjc/446999.html techarticle function Description and Example PHP collection program commonly used function query key PHP collection program commonly used functions//Get the current script URL function get_php_url () {if (!empty ($_server[re ...