国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

php 正則html表格數組保存csv與轉換數組代碼

2024-09-04 11:47:29
字體:
來源:轉載
供稿:網友
  1. <?php
  2. //html表格的每行轉為csv格式數組 
  3. function get_tr_array($table) { 
  4.  
  5. //php開源代碼 
  6.  
  7. $table = preg_replace("'<td[^>]*?>'si",'"',$table);  
  8. $table = str_replace("</td>",'",',$table);  
  9. $table = str_replace("</tr>","{tr}",$table); //開源代碼Vevb.com  
  10. //去掉 html 標記   
  11. $table = preg_replace("'<[/!]*?[^<>]*?>'si","",$table);  
  12. //去掉空白字符    
  13. $table = preg_replace("'([rn])[s]+'","",$table); 
  14.  
  15.  
  16. $table = str_replace(" ","",$table);  
  17. $table = str_replace(" ","",$table);  
  18. $table = explode(",{tr}",$table); 
  19.  
  20. array_pop($table);  
  21.         return $table;  
  22. }  
  23. ?> 
  24.  
  25. //將html表格的每行每列轉為數組,采集表格數據 
  26.  
  27. <?  
  28. function get_td_array($table) {  
  29. $table = preg_replace("'<table[^>]*?>'si","",$table); 
  30.  
  31. //osphp.com.cn 
  32.  
  33. $table = preg_replace("'<tr[^>]*?>'si","",$table);  
  34. $table = preg_replace("'<td[^>]*?>'si","",$table);  
  35. $table = str_replace("</tr>","{tr}",$table); //開源代碼Vevb.com  
  36. $table = str_replace("</td>","{td}",$table);  
  37. //去掉 html 標記   
  38. $table = preg_replace("'<[/!]*?[^<>]*?>'si","",$table); //Vevb.com開源  
  39. //去掉空白字符    
  40. $table = preg_replace("'([rn])[s]+'","",$table);  
  41. $table = str_replace(" ","",$table);//Vevb.com 
  42. $table = str_replace(" ","",$table);  
  43. $table = explode('{tr}'$table);  
  44. array_pop($table); //php開源代碼  
  45.         foreach ($table as $key=>$tr) {  
  46. $td = explode('{td}'$tr);  
  47. array_pop($td);  
  48. $td_array[] = $td//        }  
  49.         return $td_array;  
  50. }  
  51. ?> 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 海淀区| 夏津县| 油尖旺区| 东至县| 山阳县| 景德镇市| 泊头市| 开远市| 吴忠市| 慈溪市| 方山县| 原阳县| 城口县| 宣恩县| 邵武市| 托克托县| 宁波市| 南投市| 津南区| 云和县| 富顺县| 克什克腾旗| 沙雅县| 友谊县| 文登市| 广南县| 云浮市| 周口市| 汨罗市| 宁远县| 镶黄旗| 怀柔区| 临洮县| 南安市| 卓资县| 文昌市| 旺苍县| 宜城市| 罗田县| 克东县| 隆昌县|