RabPHP Posted July 16, 2008 Share Posted July 16, 2008 Hey Guys, I have a text file that is deliminated by either Semi-Colons or Pipes. I am using this function to read them and put into an array: $readfile = file("testimport1.txt"); for ($k=0; $k<=count($readfile)-1; $k++) { $fields = split(";",$readfile[$k]); One of the fields is a description containing several paragraphs. I find that this function will not recognize that the description is between semi-colons or Pipes and counts each new line in that field as a new record. Is there anyway to get around this? Rab Quote Link to comment Share on other sites More sharing options...
Xurion Posted July 16, 2008 Share Posted July 16, 2008 No because each new line is a new row/record in the file. Replace the returns with <br> maybe? Quote Link to comment Share on other sites More sharing options...
RabPHP Posted July 17, 2008 Author Share Posted July 17, 2008 Ultimately I am trying to take this data out of a huge text file that I can't control the output. If this field were enclosed with quotes is there a function or something in PHP that I can use specifically for this field? I am looking for some sort of insight into how I can make this work. Thanks for your help. Rab Quote Link to comment Share on other sites More sharing options...
Xurion Posted July 17, 2008 Share Posted July 17, 2008 Look up the fgetcsv function: http://uk.php.net/fgetcsv Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.