php將HTML表格每行每列轉為數組實現採集表格式資料的方法
本文執行個體講述了php將HTML表格每行每列轉為數組實現採集表格式資料的方法。分享給大家供大家參考。具體如下:
下面的php代碼可以將HTML表格的每行每列轉為數組,採集表格式資料
]*?>'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; } return $td_array;}?>
http://www.bkjia.com/PHPjc/979234.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/979234.htmlTechArticlephp將HTML表格每行每列轉為數組實現採集表格式資料的方法 本文執行個體講述了php將HTML表格每行每列轉為數組實現採集表格式資料的方法。分享給大...