MrAd Posted April 30, 2007 Share Posted April 30, 2007 Hi All, I am working a file based note management project and have hit a bug I cant seem to fix, I have a text file with a seperate entry on each line of the file as an example: bonus/test/** - Hello. I am writing an edit function for these notes and am having a problem with line feeds. I call up the desired line to be edited into a browser textarea and then the updated text gets written back to the file. After this the file is sorted alphabetically. The problem is if I dont use a line feed the edited line ends up stuck to the end of another line in the file whereas if I do use a line feed and there is already a line feed then I end up with dozens of extra blank lines in my file. Is there a way to check for a line feed on the end of a string, so that I can then add one if necessary? Many Thanks. Link to comment https://forums.phpfreaks.com/topic/49296-checking-for-line-feed-when-reading-from-a-file/ Share on other sites More sharing options...
monk.e.boy Posted April 30, 2007 Share Posted April 30, 2007 stristr http://uk3.php.net/stristr You need to look for a "\n" or "\r\n" did you try google? : monk.e.boy Link to comment https://forums.phpfreaks.com/topic/49296-checking-for-line-feed-when-reading-from-a-file/#findComment-241597 Share on other sites More sharing options...
MrAd Posted April 30, 2007 Author Share Posted April 30, 2007 ah, works now cheers, I was checking whether the last character of the line was an "n" which wasn't working. stristr does the job nicely. Regards. Link to comment https://forums.phpfreaks.com/topic/49296-checking-for-line-feed-when-reading-from-a-file/#findComment-241627 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.