jpt62089 Posted October 27, 2008 Share Posted October 27, 2008 I am trying to grab information from a website via PHP and when I do so there are line breaks in the source of the page. I've tried to replace \n and it didn't work. Is there a way to remove "phantom" line breaks? Did that even make sense? haha It's like viewing the source of a page. You see that there are new lines, but no function telling it to do so. Quote Link to comment https://forums.phpfreaks.com/topic/130319-remove-new-lines-that-arent-n/ Share on other sites More sharing options...
wildteen88 Posted October 27, 2008 Share Posted October 27, 2008 Pardon? Not fully understanding you. Are you saying your newlines are not being displayed? If so you'll need to convert newlines to <br /> in order for then to display on your page. PHP has a built in function which handles this for you called nl2br() Quote Link to comment https://forums.phpfreaks.com/topic/130319-remove-new-lines-that-arent-n/#findComment-675913 Share on other sites More sharing options...
DarkWater Posted October 27, 2008 Share Posted October 27, 2008 Also, when you tried to replace \n, did you have it in single quotes when you passed it in to str_replace()? You need double quotes for \n to be recognized as a newline, or just use chr(0x0A). Quote Link to comment https://forums.phpfreaks.com/topic/130319-remove-new-lines-that-arent-n/#findComment-676038 Share on other sites More sharing options...
jpt62089 Posted October 27, 2008 Author Share Posted October 27, 2008 Ok, I found out I was an idiot and was editing the wrong part of the file... Sorry! Quote Link to comment https://forums.phpfreaks.com/topic/130319-remove-new-lines-that-arent-n/#findComment-676064 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.