HTML表格的每行转为CSV格式数组
时间:2021-07-01 10:21:17
帮助过:23人阅读
HTML表格的每行转为CSV格式数组
- //HTML表格的每行转为CSV格式数组
-
- function get_tr_array($table) {
- //PHP开源代码
- $table = preg_replace("'
]*?>'si",'"',$table); - $table = str_replace("
| ",'",',$table); - $table = str_replace("
|
","{tr}",$table); //开源代码OSPhP.COm.CN //去掉 HTML 标记 $table = preg_replace("'<[/!]*?[^<>]*?>'si","",$table); //去掉空白字符 $table = preg_replace("'([rn])[s]+'","",$table);//开源代码OSPhP.COm.CN$table = str_replace(" ","",$table); $table = str_replace(" ","",$table); $table = explode(",{tr}",$table);//开源代码OSPHP.COM.Cnarray_pop($table); return $table; } ?>