- <?php
- //html表格的每行轉為csv格式數組
- function get_tr_array($table) {
- //php開源代碼
- $table = preg_replace("'<td[^>]*?>'si",'"',$table);
- $table = str_replace("</td>",'",',$table);
- $table = str_replace("</tr>","{tr}",$table); //開源代碼Vevb.com
- //去掉 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("'<table[^>]*?>'si","",$table);
- //osphp.com.cn
- $table = preg_replace("'<tr[^>]*?>'si","",$table);
- $table = preg_replace("'<td[^>]*?>'si","",$table);
- $table = str_replace("</tr>","{tr}",$table); //開源代碼Vevb.com
- $table = str_replace("</td>","{td}",$table);
- //去掉 html 標記
- $table = preg_replace("'<[/!]*?[^<>]*?>'si","",$table); //Vevb.com開源
- //去掉空白字符
- $table = preg_replace("'([rn])[s]+'","",$table);
- $table = str_replace(" ","",$table);//Vevb.com
- $table = str_replace(" ","",$table);
- $table = explode('{tr}', $table);
- array_pop($table); //php開源代碼
- foreach ($table as $key=>$tr) {
- $td = explode('{td}', $tr);
- array_pop($td);
- $td_array[] = $td; // }
- return $td_array;
- }
- ?>
新聞熱點
疑難解答