//將HTML表格的每行每列轉爲數組,採集表格數據
<?
function get_td_array($table) {
$table = preg_replace("'<table[^>]*?>'si","",$table); //OSPHP.com.CN
$table = preg_replace("'<tr[^>]*?>'si","",$table);
$table = preg_replace("'<td[^>]*?>'si","",$table);
$table = str_replace("</tr>","{tr}",$table);
//OSPHP.com.CN數組
$table = str_replace("</td>","{td}",$table);
//去掉 HTML 標記
$table = preg_replace("'<[/!]*?[^<>]*?>'si","",$table); //OSPHP.COm.CN
//去掉空白字符
$table = preg_replace("'([rn])[s]+'","",$table);
$table = str_replace(" ","",$table);
//OSPHP.com.CNide
$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; //開源代碼OSPhP.COm.CN
}
return $td_array;
}字符串
?>get
//返回字符串中的全部單詞 $distinct=true 去除重複
<?
function split_en_str($str,$distinct=true) {
preg_match_all('/([a-zA-Z]+)/',$str,$match); //PHP開源代碼
if ($distinct == true) {
$match[1] = array_unique($match[1]);
}
sort($match[1]);
//OsPHP.COM.CNit
return $match[1];
}
?>io