Php uses strip_tags () to remove html tags.
The example in this article describes how php uses strip_tags () to remove html tags. We will share this with you for your reference. The details are as follows:
$ Subject = strip_tags ($ newsRs ['content']); // remove the html Tag $ pattern = '/\ s /'; // remove blank $ content = preg_replace ($ pattern, '', $ subject); $ seodata ['articledescription'] = mb_substr ($ content, 0, 80 ); // intercept 80 Chinese Characters
Note: in step 1, The strip_tags (); only replaces the html tag with spaces.
For example:
<P> Zhang zhibin </p> <br/> </p> <p> alsdkjf; laskjd; flasj; </p> <p> asdjfasjd; lkafsj; lfdkj </p> <p> aksdjfl; ak </p>
After strip_tags () is processed, it becomes
Zhang zhibin ZHANG Zhi alsdkjf; laskjd; flasj; asdjfasjd; lkafsj; lfdkj aksdjfl; ak
This may not be what we want. Then we can use the regular expression replacement to remove the blank space.
Final result:
Zhang zhibin ZHANG Zhi alsdkjf; laskjd; flasj; asdjfasjd; lkafsj; lfdkjaksdjfl; ak
In addition, \ s indicates white space characters, and \ S indicates non-white space characters (case sensitive, generally case sensitive indicates the opposite meaning)
PS: Here are two more practical Regular Expression tools for your reference:
JavaScript Regular Expression online testing tool:
Http://tools.jb51.net/regex/javascript
Regular Expression generation tool:
Http://tools.jb51.net/regex/create_reg