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 Link to comment https://forums.phpfreaks.com/topic/114985-ignoring-new-lines-in-text-fields/ 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? Link to comment https://forums.phpfreaks.com/topic/114985-ignoring-new-lines-in-text-fields/#findComment-591380 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 Link to comment https://forums.phpfreaks.com/topic/114985-ignoring-new-lines-in-text-fields/#findComment-592115 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 Link to comment https://forums.phpfreaks.com/topic/114985-ignoring-new-lines-in-text-fields/#findComment-592243 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.