Page 1 of 1

Text Formatting Functions

Posted: Tue Dec 14, 2010 12:12 pm
by Bob42
I don't know if this is the correct forum for this topic but here goes.

I have an application where I want to use a form textarea to enter text, provide the ability to preview the text, similar to blogs, then email the completed message to multiple recipiants.

The problems come in when trying to handle HTML link code (<a href=""></a>) and hard returns. I have experimented a bit with the PHP function htmlspecialchars and have used the PHP mail function where returns must be specified as \n or \r\n.

My question is, does PHP have a function to replace hard returns with \n and is there a way to preserve HTML link code in the final email message or do I have to process the text myself? I would prefer not to implement blog-like capabilities.

Thanks for any help,
Bob

Re: Text Formatting Functions

Posted: Sat Dec 18, 2010 5:23 am
by social_experiment
Will this option be available to only you, in the role of admin, or to users in general? If it is only you doing the entering of data, you can leave away the htmlspecialchars() / htmlentities() and add a 'Content-type: text/html' header to send the email as a link. That header will let the email be sent as an html document basically.

Re: Text Formatting Functions

Posted: Mon Dec 20, 2010 10:26 am
by pickle
Are you sending a plain text email or an HTML email? If plain text, then the hard returns in the textarea will translate to hard returns in the email. Additionally, you won't be able to put <a /> tags in your email & have them parsed.

If you're sending HTML emails, you'll want to look at the nl2br() function.