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? 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 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. 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! 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
Archived
This topic is now archived and is closed to further replies.