The example in this article tells you that PHP still has a blank solution for using strip_tags () to remove HTML tags. Share to everyone for your reference, specific as follows:
$subject = Strip_tags ($newsRs [' content ']);//Remove HTML tag
$pattern = '/\s/'; remove white space
$content = preg_replace ($ Pattern, ", $subject);
$seodata [' articledescription '] = mb_substr ($content, 0, 80);//intercept 80 characters
Note: The first step of the Strip_tags (); just replace the HTML tag with a space
Like what:
<p>
Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhirong
</p>
<p>
<br/>
</p>
<p>
ALSDKJF;LASKJD;FLASJ;
</p>
<p>
asdjfasjd;lkafsj;lfdkj
</p>
<p>
Aksdjfl;ak
< /p>
Strip_tags () is processed and then changed to
Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhirong
;
ASDJFASJD;LKAFSJ;LFDKJ
Aksdjfl;ak
This may not be what we want, and then use regular substitution to remove the blanks.
Final results:
Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhibin Zhang Zhirong
In addition: \s represents a white space character, \s represents a non-white-space character (note case, general case indicates the opposite meaning)
PS: Here again for you to provide 2 more practical regular tools for your reference:
JavaScript Regular expression online test tool:
Http://tools.jb51.net/regex/javascript
Regular expression online generation tool:
Http://tools.jb51.net/regex/create_reg
More interested in PHP related content readers can view the site topics: "PHP Regular Expression Usage summary", "PHP string (String) Usage summary", "PHP Array" Operation Techniques Encyclopedia, "PHP Mathematical Arithmetic Skills summary", "PHP Data structure and algorithm tutorial" , "PHP Programming Algorithm Summary", "PHP operation and operator usage Summary" and "PHP common database Operation skill Summary"
I hope this article will help you with the PHP program design.