Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding A Header & Footer To A Generated Text File

    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:

    PHP Code:
    $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

  • #2
    Regular Coder
    Join Date
    Apr 2004
    Posts
    298
    Thanks
    0
    Thanked 23 Times in 23 Posts
    maybe sometning like this ...

    PHP Code:
    $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...

  • #3
    New Coder
    Join Date
    Jan 2004
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, thank you


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •