コードは次のとおりです:
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; } $new_content を返す; }
//すべての链接を取得
复制代码 代码如下:
function get_all_url($code){
preg_match_all('/
"' ]+)["|']?s*[^>]*>([^>]+)/i',$code,$arr); return array('name'=>$arr[2],'url'=>$arr[1]); }
//HTML表格の每行转はCSV格式数组
复制代 代码如下:
function get_tr_array($table) { $table = preg_replace("'
]*?>'si",'"',$table); $table = str_replace(" ",'",',$table); $table = str_replace("","{tr}",$table); function get_tr_array ($table) { $table = preg_replace("']*?>'si",'"',$table); $table = str_replace(" ",'",',$table); $table = str_replace("","{tr}",$table); //去掉 HTML 标记 $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); return $table; }
// HTML表格の実行列转是数组,取集表格データデータ
复制代 代码如下:
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); //去掉 HTML 标记 $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); foreach ($table as $key=>$tr) { $td = explode('{td}', $tr); array_pop($td); $td_array[] = $td; } $td_array を返す; }
//返字符中のすべての单词 $distinct=true 削除重复
复制代 代码如下:
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]); $match[1] を返す; }
http://www.bkjia.com/PHPjc/318610.html www.bkjia.com true http://www.bkjia.com/PHPjc/318610.html 技術記事 // 現在の脚本网址を取得します: functionget_php_url(){ if(!empty($_server["REQUEST_URI"])){ $scriptName=$_SERVER["REQUEST_URI"]; $nowurl=$スクリプト名; }その他{...
声明: この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。