Page 1 of 1

braking long line

Posted: Tue Sep 13, 2005 2:32 pm
by yoha
hey.. my question is pretty simple..
i have user input for some text
what i want to do? for example when i have 10 chars in a line it will go down and will not ruin my page :)

not
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
but
"aaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaa"


sorry about my bad english :)
thanks

Posted: Tue Sep 13, 2005 3:55 pm
by pickle
Use http://www.php.net/wordwrap().

Kind of like this:

Code: Select all

$user_input = '123456789012345678901234567890';
$broken_up_user_input = wordwrap($user_input,10,'<br />',1);
For wordwrap(), the first argument is what the user entered, the second argument is the width you want the string to be, the third argument is what to use as the newline character, and the last character tells wordwrap to cut the word at 10 characters.

Echoing $broken_up_user_input will give you this:

Code: Select all

1234567890<br />1234567890<br />1234567890
jcart | fixed parse error

Posted: Tue Sep 13, 2005 11:12 pm
by yoha
thanks :!: