Hongmu Notes
Home Language Notes After PHP collects data, process the function of collecting the data
Language Notes PHP

After PHP collects data, process the function of collecting the data

After PHP collects data, process the function of collecting the data

function:

function xxfseo_body($body){
	$body = preg_replace('~<(?!img)(\w+)\s+[^>]*>~i','<$1>', $body);
	$body = preg_replace("/<(iframe.*?)>(.*?)<(\/iframe.*?)>/si", "", $body);
	$body = preg_replace("/<(object.*?)>(.*?)<(\/object.*?)>/si", "", $body);
	$body = preg_replace("/<(script.*?)>(.*?)<\/script>/si", "", $body);
	$body = preg_replace("~<(|/)form([^>]*)>~i", "", $body);
	$body = preg_replace("~<input([^>]*)>~i", "", $body);
	$body = preg_replace("/<(textarea.*?)>(.*?)<\/textarea>/si", "", $body);
	$body = preg_replace("/<(botton.*?)>(.*?)<\/botton>/si", "", $body);
	$body = preg_replace("/<(select.*?)>(.*?)<\/select>/si", "", $body);
	$body = preg_replace("~<(|/)div([^>]*)>~i", "", $body);
	$body = preg_replace("~<(|/)span([^>]*)>~i", "", $body);
	$body = preg_replace("~<(|/)font([^>]*)>~i", "", $body);
	$body = preg_replace("~<(|/)a([^>]*)>~i", "", $body);
	$body = preg_replace("~<style[^>]*>(.*?)</style>~iUs", "", $body);
	$body = preg_replace("~<xml[^>]*>(.*?)</xml>~iUs", '', $body);
	$body = preg_replace("~<(|/)b>~i", "", $body);
	$body = preg_replace('~<!--(.*)-->~','', $body);
	$body = preg_replace('~<!--\[if [^\]]+\]>(.*?)<!\[endif\]-->~iUs','', $body);
	$body = preg_replace('~<(\w+)[^>]*>\s*</\\1>~Us', '', $body);
	$body = preg_replace("~[\r\n]+~",'', $body);
	$body = preg_replace("~>\s*~",'>', $body);
	$body = str_replace('</object>','', $body);
	return trim($body);
}

Very effective – ideal for HTML documents with complex post-processing requirements.

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

PHP ob function record

PHP ob function record Language Notes PHP

Usage of the following three functions ob_get_contents(); ob_end_clean(); ob_start(); You can use these functions to buffer local files and execute local script code. Use ob_start() to save the output code into the buffer, and the page will not be displayed; then use ob_get_contents to get the data in the buffer. o…
👁 140
PHP preg

PHP preg Language Notes PHP

The preg_match_all function is used to perform a global regular expression match. preg_match_all() Syntax int preg_match_all ( string $pattern , string $subject [, array &$matches [, int $flags = PREG…
👁 169
Detailed explanation of PHP ternary operator and if

Detailed explanation of PHP ternary operator and if Language Notes PHP

Ternary operator condition ? Result 1 : Result 2 Explanation: The position in front of the question mark is the condition for judgment. If the condition is met, the result is 1, and if it is not met, the result is 2. This article compares and explains the ternary operator and if...else... in detail. I hope it will be helpful to everyone. Today when I was revising my paper online, I encountered a statement that I couldn’t understand: $if_summary = $row['IF_SUMMARY']=…
👁 188
PHP cast type

PHP cast type Language Notes PHP PHP collection PHP and mysql

Get the data type 1. If you want to check the value and type of an expression, use var_dump(). 2. If you just want to get an easy-to-read type expression for debugging, use gettype(). 3. To check a certain type, do not use gettype(), but use the is_type() function. Converting Strings to Numbers When a string is evaluated as a number, the result is determined according to the following rules...
👁 232

Recommended reading

(Adaptive mobile version) Bilingual (Chinese/English) foreign trade website PBootCMS template; Automotive parts website source code download – 1031

(Adaptive mobile version) Bilingual (Chinese/English) foreign trade website PBootCMS template; Automotive parts website source code download – 1031 Practical Collection pbootcms Template

A bilingual (Chinese/English) PbootCMS website template designed for foreign trade and automotive parts businesses, compatible with both PC and WAP devices. Its professional, international design is ideal for automotive parts companies to showcase their products and brand identity. The multilingual support facilitates business expansion across global markets. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles: Pb...
👁 56
(Adaptive mobile version) Responsive high-end corporate group website PBootCMS template – Download source code for a green new energy industry group website – 0325

(Adaptive mobile version) Responsive high-end corporate group website PBootCMS template – Download source code for a green new energy industry group website – 0325 Practical Collection pbootcms Template

An adaptive, responsive PbootCMS website template designed for high-end corporate groups and green new energy industries. Its sophisticated and professional design makes it ideal for new energy industry groups to showcase their corporate strength, business segments, and social responsibility. It is an excellent choice for large green enterprises looking to establish a branded official website. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s...
👁 60
Eight Methods of the Spirit Turtle

Eight Methods of the Spirit Turtle Hobbies Memo notes

Generally used in emergencies. The stems and branches, the month number corresponds to the stems and branches, plus the hour. Five numbers, men take Zhaohai, women take Neiguan. List is missing - Zhaohai Neiguan - Gongsun Linqi - Waiguan Houxi - Shenmai Ziwu Liuzhu Men are on the left and women are on the right  
👁 1086
Responsive high-end website development – Internet marketing website template_20240807_101727 0583

Responsive high-end website development – Internet marketing website template_20240807_101727 0583 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for high-end website development and internet marketing projects. Its innovative and sophisticated design style effectively showcases premium website development cases, internet marketing services, brand strategy initiatives, and technical expertise, helping premium web development firms attract corporate clients online. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS...
👁 52
(Adaptive Mobile Version) Golf Course PBootCMS Website Template – Sports Field Website Source Code Download – 1032

(Adaptive Mobile Version) Golf Course PBootCMS Website Template – Sports Field Website Source Code Download – 1032 Practical Collection pbootcms Template

A PbootCMS website template designed for golf courses and sports venues, compatible with both PC and WAP devices. Its fresh, sporty design makes it ideal for showcasing facilities and services at golf clubs and sports venues. This template helps sports venues attract members and promote events online. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles...
👁 41
(Adaptive mobile version) Responsive high-end photography website – PBootCMS template; Download the source code for a sleek black digital photography website – 0326

(Adaptive mobile version) Responsive high-end photography website – PBootCMS template; Download the source code for a sleek black digital photography website – 0326 Practical Collection pbootcms Template

This premium adaptive mobile-responsive PbootCMS website template is designed for high-end photography and digital photography businesses – ideal for photography studios or photographers showcasing their portfolios and photography services. It helps photography agencies attract high-end clients online and enhance their brand image. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn...
👁 48