I am seeking some thoughts on if this is the way I should tackle this problem. I have two files, both of them tab delimited text files that I need to combine and then output a new file.
My idea was to put both files in an array, calling the fields I need, i.e. $field[0], $field[1] and so on. I need to loop through the entire file and output on each loop. My concern is the overhead by creating the array's. Any thoughts. Thanks, -Scott -----Original Message----- From: Paul Roberts [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 10, 2002 2:35 PM To: Scott Subject: Re: [PHP] Creating an array with a file try this, you need to get the line then explode that, fopen just returns a file handle. $file = fopen("oldfile.txt", "r"); while (!feof ($fd)) { $lines = fgets($file, 4096) $newfields = explode("\t", $lines); echo $newfields[0]."<br>"; } Paul Roberts [EMAIL PROTECTED] ++++++++++++++++++++++++ ----- Original Message ----- From: "Scott" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, February 11, 2002 5:32 PM Subject: [PHP] Creating an array with a file > Hi All, > > I am trying to create an array from a text file that I will process and > rewrite in a new format. My question is, is it possible to read the > file > in one line at a time and then separate the tab-delimited fields and > finally rewrite the new file? > > The fields are tab delimited and here is what I have attempted in code: > > $lines = fopen("oldfile.txt", "r"); > $newfields = explode("\t", $lines); > echo $newquotes[0]; > > I get a Resource ID #1 when I echo the line. > > Thanks, > > -Scott > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php