Common functions in php picker

Source: Internet
Author: User
Common functions in php collection programs: common functions in php collection programs? // Obtain the current script URL functionget_php_url () {if (! Empty ($ _ SERVER ["REQUEST_URI"]) {$ scriptName = $ _ SERVER [common functions in php collection programs

Common functions in php collection programs

?

// Obtain the current script URL 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;} // Convert a full-width number to a half-width number 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 the 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 the HTML tag function ClearHtml ($ str) {$ str = str_replace ('<', '<', $ str); $ str = str_replace ('>', '>', $ str); return $ str;} // Convert the relative path to the 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); I F ($ 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 the links to function get_all_url ($ code) {preg_match_all ('/"\'] +) [" | \ ']? \ S * [^>] *> ([^>] +) <\/a>/I ', $ code, $ arr ); return array ('name' => $ arr [2], 'URL' => $ arr [1]);} // Obtain the content in 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];} // Convert each row of the HTML table to an array in CSV format function get_tr_array ($ 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 blank character $ table = preg_replace (" '([\ r \ n]) [\ s] + '", "", $ table); $ table = str_replace ("", "", $ table); $ table = str_replace ("", "", $ table ); $ table = explode (", {tr}", $ table); array_pop ($ table); return $ table ;}// convert each column of an HTML table into an array, 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 the HTML tag $ table = preg_replace (" '<[\/\!] *? [^ <>] *?> 'Si "," ", $ table); // remove the blank character $ 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 ;} // return all words in the 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];}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.