transparencia Posted February 11, 2009 Share Posted February 11, 2009 Greetings, I need to force a line break (using the <BR /> tag) at a specific character position in a string. What is the best way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/144725-solved-best-way-to-force-a-line-break-in-html/ Share on other sites More sharing options...
lokie538 Posted February 11, 2009 Share Posted February 11, 2009 Can you explain what your trying to do some more? I don't understand sorry Quote Link to comment https://forums.phpfreaks.com/topic/144725-solved-best-way-to-force-a-line-break-in-html/#findComment-759445 Share on other sites More sharing options...
.josh Posted February 11, 2009 Share Posted February 11, 2009 wordwrap might work out for you. By default it inserts a \n at the length you specify, without breaking the word (will move the whole word to next line), but you can specify what it inserts and you can flag it to break at that length no matter what. Only problem I see with wordwrap is how long your string is. If you're only wanting to break it once, and it's a long string, it will keep adding the <br />'s every x length you specify. If that isn't going to work for you, you could always use substr to half the string at your length and concat them all together. Quote Link to comment https://forums.phpfreaks.com/topic/144725-solved-best-way-to-force-a-line-break-in-html/#findComment-759451 Share on other sites More sharing options...
transparencia Posted February 11, 2009 Author Share Posted February 11, 2009 Thank you for the responses. wordwrap() is absolutely perfect! Solved! Quote Link to comment https://forums.phpfreaks.com/topic/144725-solved-best-way-to-force-a-line-break-in-html/#findComment-759458 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.