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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Copying the contents of one file to another

    Does anyone know how to make the contents of a file a variable so they can be added to the end of another file... I tried to use !copy, not realizing that it literally copied the file onto the other. I've tried the php.net manual, but I can't find anything that works. Its probably something really simple but its been bugging me for the last hour, since I got everything else working but this.

  • #2
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    fopen() with mode a or a+
    PHP5: file_put_contents() with FILE_APPEND flag
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also file_get_contents()

    http://uk2.php.net/file-get-contents

  • #4
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Huh? file_GET_contents()?
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #5
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ahh sorry, I should have made it more clear... I was talking about an easy way to get the entire file as a string (to then be written using fopen()/fwrite()).

  • #6
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can someone explain the usage of file_get_contents since I can't seem to get anything but false whenever I use it.

  • #7
    Regular Coder
    Join Date
    Nov 2004
    Location
    The Netherlands
    Posts
    551
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    $filecontents=file(data.txt);
    $filecontents=implode('',$filecontents); 
    CATdude about IE6: "All your box-model are belong to us"

  • #8
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow! Thanks, it works


  •  

    Posting Permissions

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