最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 正则html表格数组保存csv与转换数组代码
时间:2011-01-22 编辑:简简单单 来源:一聚教程网
//html表格的每行转为csv格式数组
function get_tr_array($table) {//php教程开源代码
$table = preg_replace("'
]*?>'si",'"',$table); ",'",',$table);
$table = str_replace("
$table = str_replace("","{tr}",$table); //开源代码osphp.com.cn
//去掉 html 标记
$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);
return $table;
}
?>
//将html表格的每行每列转为数组,采集表格数据
function get_td_array($table) {
$table = preg_replace("']*?>'si","",$table);
//osphp.com.cn
$table = preg_replace("'
]*?>'si","",$table); ","{tr}",$table); //开源代码osphp.com.cn
$table = preg_replace("']*?>'si","",$table);
$table = str_replace("
$table = str_replace("","{td}",$table);
//去掉 html 标记
$table = preg_replace("'<[/!]*?[^<>]*?>'si","",$table); //osphp.com.cn开源
//去掉空白字符
$table = preg_replace("'([rn])[s]+'","",$table);
$table = str_replace(" ","",$table);
$table = str_replace(" ","",$table);
$table = explode('{tr}', $table);
array_pop($table); //php开源代码
foreach ($table as $key=>$tr) {
$td = explode('{td}', $tr);
array_pop($td);
$td_array[] = $td; // }
return $td_array;
}
?>相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24
热门栏目
php教程
php入门 php安全 php安装 php常用代码 php高级应用asp.net教程
基础入门 .Net开发 C语言 VB.Net语言 WebService手机开发
安卓教程 ios7教程 Windows Phone Windows Mobile 手机常见问题css教程
CSS入门 常用代码 经典案例 样式布局 高级应用网页制作
设计基础 Dreamweaver Frontpage js教程 XNL/XSLT办公数码
word excel powerpoint 金山WPS 电脑新手jsp教程
Application与Applet J2EE/EJB/服务器 J2ME开发 Java基础 Java技巧及代码