How to convert word text data into html using PHP
I have a html text area where users can add any text. What I want is if a user copies text from his word document or rtf and put into the text area, that text should be formatted into html using html.
I have used php's nl2br function but it just creates new lines. What I want is if there are any headings, bold, bullets in word, then they should be converted into html.
Any help will be of great use.
Thanks
Answer
Solution:
Use tinymce. It has a function that do exactly what you are asking. Just to clarify, this is a client-side script. Anyway, your user will always pass through the text area (part of a form), so it can be used and works well.
Answer
Solution:
If you are talking about posting data then use
htmlspecialchars
to avoid HTML tagsAnswer
Solution:
Look at some of the PHP and Javascript-powered WYSIWYG (what you see is what you get) text editors, such as tinymce. These generally can handle such things, and you can look at the source to get an idea of how it's done.