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.





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.




If you are talking about posting data then usehtmlspecialchars to avoid HTML tags




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.

People are also looking for solutions to the problem: php - How to create a Phar archive without index?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.