$delimiter = "\t"; $file = "path/to/file/name.ext"; if($file = fopen($file, "r")) { $file_array = file($file); foreach($file_array AS $str) { $new_array[] = explode($delimiter, $file_array); } }
now when you are done you will have an indexed array called new_array that contains your rows broken up into key=>value pairs. Jim ----- Original Message ----- From: "Chris Steitz" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, December 24, 2001 9:12 AM Subject: [PHP] Reading semi formatted text file 201 PNCPS FINANCIAL ACCT 10027 3 8.00- 8.50 MWF GSB 400 I have a text file with rows similar to that above. I need to read the data in the rows into an array. fscanf likes to split the line into elements by spaces and I get 201,PNCPS,FINANCIAL,ACCT etc... and I need results like 201,PNCPS FINANCIAL ACCT,10027 etc... data[1]=201 data[2]=PNCPS FINANCIAL ACCT data[3]=10027 data[4]=3 data[5]=8.00 data[6]=8.50 data[7]=MWF data[8]=GSB 400 Can anybody provide any help on how to do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]