In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use php to get rid of rich text styles, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Php to remove the rich text style method: 1, open the corresponding files in the project; 2, through the "function cutstr_html () {...}" method to remove all Html tag spaces; 3, call the "cutstr_html" method to remove the text style.
This article operating environment: Windows7 system, PHP7.1, Dell G3 computer.
How does php get rid of rich text styles?
Php removes content formatting from rich text editors
In a new project, you need to display the first few lines of plain text in the article list page, because the background is the article added through a rich text editor, and the data returned directly is formatted data, resulting in confusion in the style of the list page. so you need to remove the format and return plain text data.
/ * * remove all Html tags, spaces and whitespace, and intercept the string (including Chinese) * @ param string $string string * @ param number $sublength string length * @ param string $encoding encoding * @ param string $ellipsis ellipsis * / function cutstr_html ($string,$sublength,$encoding = 'utf-8',$ellipsis =' …') {$string = strip_tags ($string); $string = trim ($string); $string = mb_ereg_replace ("\ t", "", $string); $string = mb_ereg_replace ("\ r\ n", "", $string); $string = mb_ereg_replace ("\ r", "", $string); $string = mb_ereg_replace ("\ n", "", $string); $string = mb_ereg_replace ("", ", $string) If (mb_strlen (trim ($string), 'utf-8') < $sublength) {return trim ($string). $ellipsis;} else {return mb_strcut (trim ($string)). $ellipsis;}} / / Test string $str=' fherfhewkolfjlkdsjfld
'; / / call the method to test echo cutstr_html ($string=$str,$sublength=5,$encoding='utf-8',$ellipsis='...')
The output is a plain text string of length 5, which can be displayed in the article list.
On how to use php to get rid of the rich text style to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.