Re[2]: [PHP] remove header tags - include file
| From: | Asmodean | Date: | Wed, 17 Jul 2002 17:39:13 +0000 |
| Subject: | Re[2]: [PHP] remove header tags - include file | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108128@lists.php.net to get a copy of this message | ||
JPA> >Do you mean you want to include the file
JPA> html.html but not the "<html>...</head>" part?
JPA> Yes!!. In other words I just want show the part inside of <body> tag of the
JPA> html.html
JPA> I know the answer is in a Regulars expression.. but.. i don't know much
JPA> about it.
JPA> At 19:08 17-07-2002, you wrote:
>>JPA> Hi guys, me again.
>>JPA> (thanks kevin, but i'm afraid you didn't understand me).
>>
>>JPA> After looking for untiringly in the archives I have I decide to ask
>>again.
>>
>>JPA> This is my problem:
>>JPA> I want include the file html.html inside of my file index.php, but
>>before
>>JPA> include it I want to remove <html>..</head> tags from my html.html file.
>>JPA> My pseudo code would be look like this:
>>
>>JPA> > index.php
>>
>>JPA> <?php
>>
>>JPA> include_once("common.php");
>>
>>JPA> header("Welcome to my page");
>>JPA> include_html_file("html.html");
>>JPA> footer()
>>?>>
>>
>>
>>JPA> > common.php
>>JPA> function include_html_file($f)
>>JPA> {
>>JPA> (your kind contribution:-) )
>>JPA> }
>>
>>JPA> thanks!!
>>
>>JPA> --jp
>>
>>How do you mean remove? Do you mean you want to include the file
>>html.html but not the "<html>...</head>" part? And why?
>>
>>--
>>Best regards,
>> Asmodean mailto:asmodean@lka.nu
>>
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
JPA> ________________________________________________________
JPA> Juan Pablo Aqueveque <juque@uct.cl>
JPA> Ingeniero de Sistemas
JPA> Departamento de Redes y Comunicaciones http://www.drc.uct.cl
JPA> Universidad Católica de Temuco.
JPA> Tel:(5645) 205 630 Fax:(5645) 205 628
Seems like a... strange thing to do. Anyway. Since I do not know of
any other way (if there is, anyone, tell), this is what you will have
to do.
1. Open the file with fopen()
2. Perform a regular expression on the content
3. Print the parsed cntents
For example:
$fp = fopen('html.html', 'r');
$content = fread($fp, filesize(html.html));
preg_match("/<body>(.*?)<\/body>/s", $content, $matches);
The parsed contents are now in $matches[1].
I still don't understand why you want to do this, though. Seems like
there must be a better way.
--
Best regards,
Asmodean mailto:asmodean@lka.nu