Schlo_50 Posted September 22, 2008 Share Posted September 22, 2008 Hello, I'm using a flat file database and getting problems when carriage returns occur in the middle of lines. This happens, for example, when the text comes from a web form TEXTAREA field. How can I strip and replace such carriage return characters with the word [break] and keep everything on one line/row? The following code replaces \n with [break] but when I view the datebase everything is still on a new line ???. $input = str_replace("\n", "[break]", $_POST[$key]); Any help with this would be great! Thanks Link to comment https://forums.phpfreaks.com/topic/125278-solved-handling-mid-line-carriage-returns-in-a-flatfile-database/ Share on other sites More sharing options...
Mchl Posted September 22, 2008 Share Posted September 22, 2008 You should also replace \r and \r\n Link to comment https://forums.phpfreaks.com/topic/125278-solved-handling-mid-line-carriage-returns-in-a-flatfile-database/#findComment-647567 Share on other sites More sharing options...
Schlo_50 Posted September 22, 2008 Author Share Posted September 22, 2008 Wicked. I used: $input = str_replace("\r\n", "[break]", $_POST[$key]); Thanks! Link to comment https://forums.phpfreaks.com/topic/125278-solved-handling-mid-line-carriage-returns-in-a-flatfile-database/#findComment-647579 Share on other sites More sharing options...
Mchl Posted September 22, 2008 Share Posted September 22, 2008 Use $input = str_replace(array("\r\n","\r","\n"), "[break]", $_POST[$key]); If you're interested in why it's so wicked, read this Link to comment https://forums.phpfreaks.com/topic/125278-solved-handling-mid-line-carriage-returns-in-a-flatfile-database/#findComment-647593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.