《PHP編程:php將HTML表格每行每列轉(zhuǎn)為數(shù)組實(shí)現(xiàn)采集表格數(shù)據(jù)的方法》要點(diǎn):
本文介紹了PHP編程:php將HTML表格每行每列轉(zhuǎn)為數(shù)組實(shí)現(xiàn)采集表格數(shù)據(jù)的方法,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
本文實(shí)例講述了php將HTML表格每行每列轉(zhuǎn)為數(shù)組實(shí)現(xiàn)采集表格數(shù)據(jù)的辦法.分享給大家供大家參考.具體如下:PHP應(yīng)用
下面的php代碼可以將HTML表格的每行每列轉(zhuǎn)為數(shù)組,采集表格數(shù)據(jù)PHP應(yīng)用
<?php function get_td_array($table) { $table = preg_replace("'<table[^>]*?>'si","",$table); $table = preg_replace("'<tr[^>]*?>'si","",$table); $table = preg_replace("'<td[^>]*?>'si","",$table); $table = str_replace("</tr>","{tr}",$table); $table = str_replace("</td>","{td}",$table); //去掉 HTML 標(biāo)記 $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; } ?>
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所贊助.PHP應(yīng)用
《PHP編程:php將HTML表格每行每列轉(zhuǎn)為數(shù)組實(shí)現(xiàn)采集表格數(shù)據(jù)的方法》是否對(duì)您有啟發(fā),歡迎查看更多與《PHP編程:php將HTML表格每行每列轉(zhuǎn)為數(shù)組實(shí)現(xiàn)采集表格數(shù)據(jù)的方法》相關(guān)教程,學(xué)精學(xué)透。維易PHP學(xué)院為您提供精彩教程。
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.snjht.com/jiaocheng/11116.html