In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Xiaobian to share with you whether php can delete html tag content, I hope you have gained something after reading this article, let's discuss it together!
php can delete html tag content, the specific methods are: 1, use php's own function strip_tags to delete all or retain the specified html tag;2, through the strip_html_tags() function to delete the specified html tag and tag content, and so on.
Operating environment: Windows 7 system, PHP 7.1 version, Dell G3 computer.
php delete html tags and tags inside the method
Often dig other people's website articles pit people; I mean the kind of batch collection does not look at the content, and will inevitably use the function to delete html tags; here are three different uses of the method;
$str='
Here's the p tag.
Here's the a-tag.
';
1: Delete all or keep specified html tags
php comes with the function strip_tags can meet the requirements,
strip_tags(string,allow);
string: string to be processed;
allow: the specified label to be retained, multiple labels can be written;
//Output:
Here's the p tag.
Here's the a-tag.
The advantage of the subfunction is simple and rude, but the disadvantage is also obvious; if there are a lot of labels; and I just want to delete a specified one; then write a lot of labels that need to be preserved; so there is a second method;
2: Delete the specified html tag
strip_html_tags($tags,$str);
$tags: tags to delete (array format)
$str: string to be processed;
//output here is p label here is a label
;
3: Delete labels and label content
strip_html_tags($tags,$str);
$tags: tags to delete (array format)
$str: string to be processed;
//Output
Here's the p tag.
;
Many website articles will bring website names and links, such as Bai Junyao blog; this function is exclusive to this; do not take this function collection site ah; otherwise guarantee not to kill you;
4: Ultimate function, delete the specified label; delete or retain the contents of the label;
strip_html_tags($tags,$str,$content);
$tags: tags to delete (array format)
$str: string to be processed;
$content: Delete the content in the tag 0 Keep the content 1 Do not keep the content
//Output
Here's the p tag.
After reading this article, I believe you have a certain understanding of "php can delete html tag content", if you want to know more about relevant knowledge, welcome to pay attention to the industry information channel, thank you for reading!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.