dsjoes Posted March 16, 2011 Share Posted March 16, 2011 i am using the below script that i got from the php manual but it is putting to many <br /> in. script from php manual <?php $string_text=file_get_contents("newsletter_files/newsletter.txt"); // load text file in var $new_text=nl2br($string_text); // convert CR & LF in <br> in newvar echo $new_text; // print out HTML formatted text unset($string_text, $new_text); // clear all vars to unload memory ?> this is the source view <div class="maintext"><center><h1>Newsletter</h1></center><br /> <br /> text here<br /> <br /> text here</div> this is what i put in the text file <center><h1>Newsletter</h1></center> text here text here Quote Link to comment https://forums.phpfreaks.com/topic/230808-nl2br/ Share on other sites More sharing options...
dflow Posted March 16, 2011 Share Posted March 16, 2011 what is the text like? Quote Link to comment https://forums.phpfreaks.com/topic/230808-nl2br/#findComment-1188180 Share on other sites More sharing options...
dsjoes Posted March 16, 2011 Author Share Posted March 16, 2011 this is the source view <div class="maintext"><center><h1>Newsletter</h1></center><br /> <br /> text here<br /> <br /> text here</div> sorry wrote wrong thing the script is making a really big gap between the title newsletter and the first line of text not all of the text it looks like 4-5 line spaces Quote Link to comment https://forums.phpfreaks.com/topic/230808-nl2br/#findComment-1188186 Share on other sites More sharing options...
floridaflatlander Posted March 16, 2011 Share Posted March 16, 2011 h1 has margin and padding around it anyway so that needs to be set to 0; I think you have h1 with margin & padding <br /> break 1 with margin & padding, maybe, I can't remember <br /> break 2 with margin & padding, maybe text here with margin & padding <br /> with margin & padding <br /> with margin & padding text here with margin & padding </div> Can you remove some breaks and playwith it ? Also use Firefox's Firebug, it helps a lot and tells you what and where the margin & padding is Quote Link to comment https://forums.phpfreaks.com/topic/230808-nl2br/#findComment-1188196 Share on other sites More sharing options...
dsjoes Posted March 16, 2011 Author Share Posted March 16, 2011 i all ready have set the margin and padding to 0 h1, h2, h3, h4, h5, h6, p { margin-top: 0px; margin-bottom:: 0px; padding-bottom: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; } and i will have a look at fire bug Quote Link to comment https://forums.phpfreaks.com/topic/230808-nl2br/#findComment-1188258 Share on other sites More sharing options...
floridaflatlander Posted March 16, 2011 Share Posted March 16, 2011 I think you have to many breaks for what you want to do. have you tried removing nl2br the h1 tag and the text should naturally create their own line. Quote Link to comment https://forums.phpfreaks.com/topic/230808-nl2br/#findComment-1188263 Share on other sites More sharing options...
dsjoes Posted March 17, 2011 Author Share Posted March 17, 2011 ok i have been messing with this bit <center><h1>Newsletter</h1></center> it display ok with out the tags but if i just have center tags that adds a small gap but when i ass the h1 tags it adds the big gap but if i have both then it is just the big gap so the css i posted earlier is not working. anyone know what i could try? Quote Link to comment https://forums.phpfreaks.com/topic/230808-nl2br/#findComment-1188460 Share on other sites More sharing options...
cyberRobot Posted March 17, 2011 Share Posted March 17, 2011 I think the issue is due to the margin-bottom declaration having an extra colon. margin-bottom:: 0px; Also, you could simplify the CSS with h1, h2, h3, h4, h5, h6, p { margin:0; padding:0; } Quote Link to comment https://forums.phpfreaks.com/topic/230808-nl2br/#findComment-1188624 Share on other sites More sharing options...
floridaflatlander Posted March 17, 2011 Share Posted March 17, 2011 Try cyberrobot's idea first, he has good eyes I didn't see the double colon yesterday. You can also try <h1 style="margin: 0; padding: 0; text-align:center;">Newsletter</h1> if you have a problem with inheritence. But this will make your code bulky in the long run if you use it a lot, your's should work once you remove the colon, use firebug to check for inheritence. Quote Link to comment https://forums.phpfreaks.com/topic/230808-nl2br/#findComment-1188625 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.