jollydonkey
Technical User
Hello,
I'm having some issues with properly formatting text extracted from an online form using a textarea box. Output will be a plain text email.
Here's what I need:
-- text should wrap at 72 characters
-- for lengthy lines, breaks (\n) should only occur after 72 characters
-- if a user creates a hard return or inserts a blank line in the textarea box, breaks should occur at that point.
For example, if the input is:
The output should be:
Is there a simple solution here? I've tried using wordwrap and nl2br as follows:
Any help would be greatly appreciated. Be gentle - I'm a newbie
I'm having some issues with properly formatting text extracted from an online form using a textarea box. Output will be a plain text email.
Here's what I need:
-- text should wrap at 72 characters
-- for lengthy lines, breaks (\n) should only occur after 72 characters
-- if a user creates a hard return or inserts a blank line in the textarea box, breaks should occur at that point.
For example, if the input is:
Code:
The lazy fox jumped over the cow. The lazy
fox jumped over the cow.[hard return]
[hard return]
Baa Baa[hard return]
Black Sheep.
The output should be:
Code:
The lazy fox jumped over the cow. The lazy fox jumper over the cow...72characters\n\n
Baa Baa\n
Black Sheep.
Is there a simple solution here? I've tried using wordwrap and nl2br as follows:
Code:
[red]
$string = wordwrap($string, 72, "\n");
$string = nl2br($string);
[/red]