欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php將HTML表格每行每列轉(zhuǎn)為數(shù)組實(shí)現(xiàn)采集表格數(shù)據(jù)的方法

 更新時間:2015年04月03日 16:01:06   作者:pythoner  
這篇文章主要介紹了php將HTML表格每行每列轉(zhuǎn)為數(shù)組實(shí)現(xiàn)采集表格數(shù)據(jù)的方法,涉及php正則替換的技巧,非常具有實(shí)用價值,需要的朋友可以參考下

本文實(shí)例講述了php將HTML表格每行每列轉(zhuǎn)為數(shù)組實(shí)現(xiàn)采集表格數(shù)據(jù)的方法。分享給大家供大家參考。具體如下:

下面的php代碼可以將HTML表格的每行每列轉(zhuǎn)為數(shù)組,采集表格數(shù)據(jù)

<?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;
}
?>

希望本文所述對大家的php程序設(shè)計有所幫助。

相關(guān)文章

最新評論