This article mainly introduces how to delete the width and height styles in the HTML code using PHP regular expressions, and involves php's operations on HTML code such as regular matching and replacement, for more information about how to delete the width and height styles in HTML code using PHP regular expressions, such as regular matching and replacement of HTML code, for more information, see
This article describes how to delete the width and height styles in HTML code using PHP regular expressions. We will share this with you for your reference. The details are as follows:
For work purposes, you need to collect html and save the html content to the database. To avoid impact on use, you must delete the width and height styles. Width and height in sample and p.
However, in the collected html, styles are written differently, such as case and space in the middle.
Therefore, the following method is compiled using php regular expressions to filter out these wonderful styles.
The code is as follows:
Demo:
HTML; echo'
& #39; echo & #39; original content: & #39 ;. PHP_EOL; echo $ html. PHP_EOL.PHP_EOL; echo & #39; filtered content: & #39 ;. PHP_EOL; echo clear_wh ($ html); echo & #39;
';?>
Output:
Original content:
Filtered content:
The above is a detailed explanation of how PHP deletes the width and height styles in HTML. For more information, see other related articles in the first PHP community!