有没有更有效的方法来做到这一点? [英] Is there a more efficient way to do this?

查看:77
本文介绍了有没有更有效的方法来做到这一点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP 4.3。我有15页,其中我需要把BODY的

内容放在一张小桌子上......


< table>

< tr>< td colspan =" 3">< img src =" header.gif">< / td>< / tr>

< tr>

< td>< img src =" left_img.gif">< / td>

< td>< ; - - 正文内容在这里 - >< / td>

< td>< img src =" right_img.gif">< / td>

< / tr>

< tr>< td colspan =" 3">< img src =" bottom.gif">< / td> ;< / tr>

< / table>


必须剪切并粘贴所有这些HTML代码是很痛苦的(上面是<所有15个页面中的
只是一个缩写版本。而且,如果外壳

发生变化,我将不得不在15页内进行更改。有关

有效方法的建议吗?


谢谢, - 戴夫

解决方案

la *********** @ zipmail .com 写道:


我正在使用PHP 4.3。我有15页,其中我需要把BODY的

内容放在一张小桌子上......


< table>

< tr>< td colspan =" 3">< img src =" header.gif">< / td>< / tr>

< tr>

< td>< img src =" left_img.gif">< / td>

< td>< ; - - 正文内容在这里 - >< / td>

< td>< img src =" right_img.gif">< / td>

< / tr>

< tr>< td colspan =" 3">< img src =" bottom.gif">< / td> ;< / tr>

< / table>


必须剪切并粘贴所有这些HTML代码是很痛苦的(上面是<所有15个页面中的
只是一个缩写版本。而且,如果外壳

发生变化,我将不得不在15页内进行更改。有什么建议

有效的方法将其添加到一切?


谢谢, - Dave



使用file_get_contents()获取文件内容,然后用正则表达式取出正文

。类似于:


s = file_get_contents(" bobo.html");

preg_match(" /< \\ ?\\s *体* GT;<(*); \ / \s *体* GT; /?是",

S,

Hi, I''m using PHP 4.3. I have 15 pages in which I need to take the
content of the BODY and put it in a little table ...

<table>
<tr><td colspan="3"><img src="header.gif"></td></tr>
<tr>
<td><img src="left_img.gif"></td>
<td><!-- body content goes here --></td>
<td><img src="right_img.gif"></td>
</tr>
<tr><td colspan="3"><img src="bottom.gif"></td></tr>
</table>

It is a pain to have to cut and paste all this HTML code (the above is
just an abbreviated version) into all 15 pages. And plus, if the shell
changes, I''ll have to change it in 15 pages. Any advice on an
efficient way to add this to everything?

Thanks, - Dave

解决方案

la***********@zipmail.com wrote:

Hi, I''m using PHP 4.3. I have 15 pages in which I need to take the
content of the BODY and put it in a little table ...

<table>
<tr><td colspan="3"><img src="header.gif"></td></tr>
<tr>
<td><img src="left_img.gif"></td>
<td><!-- body content goes here --></td>
<td><img src="right_img.gif"></td>
</tr>
<tr><td colspan="3"><img src="bottom.gif"></td></tr>
</table>

It is a pain to have to cut and paste all this HTML code (the above is
just an abbreviated version) into all 15 pages. And plus, if the shell
changes, I''ll have to change it in 15 pages. Any advice on an
efficient way to add this to everything?

Thanks, - Dave

Get the file contents with file_get_contents(), then pluck out the body
with a regular expression. Something like:


s = file_get_contents("bobo.html");
preg_match("/<\s*body.*?>(.*?)<\/\s*body.*?>/is",


s,


这篇关于有没有更有效的方法来做到这一点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆