Php cleanup of html functions generated by word-php Tutorial

Source: Internet
Author: User
Php clears html functions generated by word
When you use FCKedior or ueditor, the content pasted from word will generate many additional tags. This article will share a function to clear this extra html code, for more information, see.

Note: When FCKedior or ueditor is used, many additional labels will be generated when it is pasted from word. This section shares a code example to clear the html code generated by word. Example:

     
') {Mb_regex_encoding ('utf-8'); $ search = array ('/U', '/U','/"/U ', '/"/U','/-/u'); $ replace = array ('\'','\'','"','"', '-'); $ text = preg_replace ($ search, $ replace, $ text); $ text = html_entity_decode ($ text, ENT_QUOTES, 'utf-8 '); if (mb_stripos ($ text ,'/*')! = FALSE) {$ text = mb_eregi_replace ('#/\*.*? \ */# S ', '', $ text, 'M');} $ text = preg_replace (array ('/<([0-9] +) /'), array (' <$ 1'), $ text); $ text = strip_tags ($ text, $ allowed_tags ); $ text = preg_replace (array ('/^ \ s +/', '/\ s + $ /', '/\ s +/u'), array ('','', ''), $ text ); $ search = array ('# <(strong | B) [^>] *> (. *?) # Isu', '# <(em | I) [^>] *> (.*?) # Isu ','# ] *> (.*?)
# Isu '); $ replace = array ('$2','$2','$1'); $ Text = preg_replace ($ search, $ replace, $ text); $ num_matches = preg_match_all ("/\

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.