国产探花免费观看_亚洲丰满少妇自慰呻吟_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. ?> 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巴楚县| 益阳市| 股票| 家居| 灵山县| 平谷区| 隆回县| 原平市| 定州市| 大庆市| 合作市| 新安县| 拉萨市| 历史| 霍山县| 洪湖市| 板桥市| 南皮县| 永登县| 崇文区| 兴安县| 岳阳市| 叙永县| 闸北区| 岳普湖县| 安岳县| 漾濞| 全椒县| 白水县| 宕昌县| 怀仁县| 高邑县| 礼泉县| 突泉县| 南京市| 梁山县| 互助| 曲阜市| 大新县| 扎兰屯市| 吉水县|