...

View Full Version : Adding A Header & Footer To A Generated Text File



Pee-H-Pee
09-24-2004, 11:13 PM
I am generating a text file with one line per record. But I need to also include a header and footer to add information to the bottom and top of the generated text file.

This is what I have so far:


$line = "STUFF PULLED FROM THE DATABASE";

//Generate the text file here
$fp = fopen("file.txt", 'a');
chmod("file.txt", 0777);
fwrite($fp, $line);
fclose($fp);

So I need the file.txt to show:

HEADER INFO HERE

Database Stuff Here generated by the above PHP code

FOOTER INFO HERE

Hope that made sense :D

litebearer
09-25-2004, 04:52 AM
maybe sometning like this ...



$header ="This is the top of my page, itwas created today" . "\r\n";
$footer ="\r\n" . "Thanks for reading this file";

$line = "STUFF PULLED FROM THE DATABASE";
$content = $header . $line . $footer;

//Generate the text file here
$fp = fopen("file.txt", 'a');
chmod("file.txt", 0777);
fwrite($fp, $content);
fclose($fp);

is that what you had in mind?

Lite...

Pee-H-Pee
09-25-2004, 01:16 PM
Yes, thank you :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum