You are here: Re: Is there a more efficient way to do this? « PHP Programming Language « IT news, forums, messages
Re: Is there a more efficient way to do this?

Posted by Chung Leong on 08/15/06 15:02

laredotornado@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, $m);
$body = $m[1];

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация