Results 1 to 5 of 5

Thread: fwrite() !!!!

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

    Question fwrite() !!!!

    Please tell me what's wrong with my following lines of code while I am trying to write in a text file.

    PHP Code:

    <?php

    $file
    ="list1.txt";
    $file_array=file($file);

    $handle=fopen("list2.txt","a");

    foreach(
    $file_array as $line)
    {
          
    fwrite($handle,$line);
    }

    fclose($handle);

    ?>
    Thank you so much for help.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: fwrite() !!!!

    I don't know what's wrong. What is the error message? Or, if there's no error message, what does it do?

    You know you could just:
    PHP Code:
    copy('list1.txt''list2.txt'); 

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: fwrite() !!!!

    It gets the content of the file as an array. Then loops through the array and writes it back to the end of the same file. So copy wouldn't work :P
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: fwrite() !!!!

    No it doesn't, his code writes to a different file.

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: fwrite() !!!!

    Quote Originally Posted by penagate
    No it doesn't, his code writes to a different file.
    It appends it though. Rather than copy.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width