如何删除php文件中<body>标签的内容 <?php ....?><html><head></head><body> .....</body></html>红字部分为欲删除内容注:是文件中<body>标签的代码要删掉 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 preg_replace(/\<body\>.*\<\/body\>/, '', file_get_contents('你的文件名')); 正则表达式绝对是必要的 `既然body都不要了.head也一并删了吧.哈哈 `~ str_replace('<body>','',$yourFile); preg_replace('!^<body (.*)?>.*</\body>$!','',file_get_content('你的文件名')); //$str 当然,用file_get_content(filePath)获取比较方便$str = '<html><head></head><body>.....</body></html>';echo preg_replace('/<body>.*<\/body>/s', '', $str); 请教高手: windows 2003 PHP 提示 No input file specified. 求正则表达式 开启xdebug进行测试开发,apache占用内存越来越大 关于表单无法提交的问题 只有一个小时了,求一个写好的生成excel的类 这两个的区别 [急]后台登陆问题? msyql 如何日期相减 图片较多的网站怎么搭建 我现在在实习从事.net的工作,但是收到了做php的工作录取,现在犹豫不决 php数据匹配 php有没有格式化html的类?
既然body都不要了.head也一并删了吧.哈哈 `~
str_replace('<body>','',$yourFile);
//$str 当然,用file_get_content(filePath)获取比较方便
$str = '<html>
<head>
</head><body>
.....
</body></html>
';
echo preg_replace('/<body>.*<\/body>/s', '', $str);