In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge about "PHP how to remove the unformatted functions pasted from word". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
There are two ways to deal with it: 1. Remove it directly through JS of the editor. 2. After submitting to the background, use the program to remove the invalid label directly. Below I will share a processing method through PHP, the success rate may not be 100%. This program is also seen on PHP's official website, and it is pasted by the way.
The copy code is as follows:
function ClearHtml($content,$allowtags='') {
mb_regex_encoding('UTF-8');
//replace MS special characters first
$search = array('/‘/u', '/’/u', '/“/u', '/”/u', '/-/u');
$replace = array('\'', '\'', '"', '"', '-');
$content = preg_replace($search, $replace, $content);
//make sure _all_ html entities are converted to the plain ascii equivalents - it appears
//in some MS headers, some html entities are encoded and some aren't
$content = html_entity_decode($content, ENT_QUOTES, 'UTF-8');
//try to strip out any C style comments first, since these, embedded in html comments, seem to
//prevent strip_tags from removing html comments (MS Word introduced combination)
if(mb_stripos($content, '/*') !== FALSE){
$content = mb_eregi_replace('#/\*.*?\*/# s', '', $content, 'm');
}
//introduce a space into any arithmetic expressions that could be caught by strip_tags so that they won't be
//'(.*?)# isu', '#]*>(.*?)# isu');
$replace = array('$2', '$2', '$1');
$content = preg_replace($search, $replace, $content);
//on some of the ? newer MS Word exports, where you get conditionals of the form 'if gte mso 9', etc., it appears
//that whatever is in one of the html comments prevents strip_tags from eradicating the html comment that contains
//some MS Style Definitions - this last bit gets rid of any leftover comments */
$num_matches = preg_match_all("/\
"Excellent companion outdoor travel"-make travel a habit!
As you get busier, do you want to take a vacation? Do you remember the last time you worked out? Excellent companion outdoor travel, give you a different travel experience: give heart freedom, then everywhere is scenery!
';
echo ClearHtml($content,'
');
/*
Results obtained:
"Excellent companion outdoor travel"-make travel a habit!
As you get busier, do you want to take a vacation? Do you remember the last time you worked out? Excellent companion outdoor travel, give you a different travel experience: give heart freedom, then everywhere is scenery!
*/
?>
"PHP how to remove the paste from the word did not use the format of the function" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.