This article mainly introduces PHP using Strip_tags () to remove HTML tags still have a blank solution, involving PHP regular replacement of the relevant operational skills, the need for friends can refer to the following
This article explains how PHP uses Strip_tags () to remove HTML tags and still have blank solutions. Share to everyone for your reference, as follows:
$subject = Strip_tags ($newsRs [' content ']);//Remove HTML tag $pattern = '/\s/';//Remove Blank $content = preg_replace ($pattern, ', $ subject); $seodata [' articledescription '] = mb_substr ($content, 0, 80);//intercept 80 characters
Note: Strip_tags () in the first step; just replace the HTML tag with a space
Like what:
<p> Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhijin </p><p> <br/></p><p> ALSDKJF;LASKJD;FLASJ ;</p><p> asdjfasjd;lkafsj;lfdkj</p><p> aksdjfl;ak</p>
Strip_tags () after processing becomes
Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhijin alsdkjf;laskjd;flasj ; ASDJFASJD;LKAFSJ;LFDKJ Aksdjfl;ak
This may not be what we want, and then we'll just remove the blanks with a regular replacement.
Final Result:
Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhijin Alsdkjf;laskjd;flasj;asdjfasjd;lkafsj;lfdkjaksdjfl;ak
In addition: \s denotes whitespace characters, \s denotes non-whitespace characters (note case, general case indicates the opposite meaning)
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!