DulongC Posted June 29, 2011 Share Posted June 29, 2011 I am having an issue that I cannot figure out. I'm using the nl2br() function to format user entered text stored in the DB as necessary and it has never been an issue. However, for one particular entry it is giving my a problem. If I just echo the data out of the DB it displays fine, however as soon as I add the nl2br I get a huge number of unnecessary BR tags. Here is the problem area from the data in the DB: <p> The below table outlines all the ranks available in the WCC. You should view Appendix C to find out the minimum requirements for each, and which sections are currently inactive. </p><table style=\"border: 1px solid #f3a61f; margin-left: auto; margin-right: auto; width: 90%; border-collapse: collapse; text-align: center;\" border=\"0\"> And the source code when I run it through nl2br: <p> The below table outlines all the ranks available in the WCC. You should view Appendix C to find out the minimum requirements for each, and which sections are currently inactive. Okay</p><br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <table style="border: 1px solid rgb(243, 166, 31); margin-left: auto; margin-right: auto; width: 90%; border-collapse: collapse; text-align: center;" border="0"> Quote Link to comment https://forums.phpfreaks.com/topic/240737-nl2br-function-creating-large-gap/ Share on other sites More sharing options...
xyph Posted June 29, 2011 Share Posted June 29, 2011 Try trim() 'ing the data before you nl2br. See what happens. Quote Link to comment https://forums.phpfreaks.com/topic/240737-nl2br-function-creating-large-gap/#findComment-1236490 Share on other sites More sharing options...
DulongC Posted June 29, 2011 Author Share Posted June 29, 2011 still getting the same thing with the trim() Quote Link to comment https://forums.phpfreaks.com/topic/240737-nl2br-function-creating-large-gap/#findComment-1236493 Share on other sites More sharing options...
requinix Posted June 29, 2011 Share Posted June 29, 2011 Instead of nl2br() try $string = preg_replace('/([ \t]|\n|\r\n?)+/', " ", $string); Quote Link to comment https://forums.phpfreaks.com/topic/240737-nl2br-function-creating-large-gap/#findComment-1236500 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.