Hey guys, I was just wondering if I should use the 'b' flag when opening and writing to .inc and .php files (Im using windows). If I use the b flag should I then use the /n as the newline character? I also check for blank lines from a text area withen a form - at the moment I check for multiple instances of /r/n and recursively replace them with /r/n until I have just one instance - I understand that different operating systems use different end of line characters, so should I be checking for /r/n, /n and /r instead? I also have a function that replaces /r/n with a </br> again should I be checking for /n and /r as well. Thanks for your help
You do not use the 'b' flag. It is used for binary files and the files you want to access are text files. I use Windows and Linux environments interchangeably and I only use "\n" to denote a newline. This is correctly translated by most windows text editors. Converting newlines to "<br />" tags? To be safe, yes, consider all possibilities. However, it has been a long time since I have encountered the need to replace anything more than "\n" newline feeds.
You use the 'b' flag if you want to write an image file or something like that you get from some other source. You can use \n by itself. Or maybe, you can detect the OS and make the correct newline character according to that . I like making things difficult . Its not that difficult tho. As for replacing them with <br />, I think you can use an array in str_replace like this: $newtext = str_replace(array('\r\n','\n','\r'),"<br />",$text); I am not very sure about this. I think I used this somewhere but I dont remember... Thomas