tags:

views:

150

answers:

2

I know about the nl2br function... But is there a way to set a maximum length of a line? Im using php to get results from a form, which contains a textarea. I dont want words to get broken to newlines, like the word 'example' to become 'exa
mple'

Thanks

+3  A: 

You can use wordwrap to force a line break:

wordwrap($str, 123, "<br>\n", true)
Gumbo
anyway to wrap before php, just with html? I dont want the text to be weird, like break in the middle of a word...
Camran
@camran: The fourth parameter is for the hard cut after the exact number of given bytes.
Gumbo
textarea has `cols` but that's not a new line, just a presentation wrap.
Nerdling
+2  A: 

You might be interested in the wordwrap function in php.

Tomas Markauskas