note 55623 deleted from function.preg-replace by mazzanet
| From: | mazzanet@php.net | Date: | Tue, 09 Aug 2005 08:04:43 +0000 |
| Subject: | note 55623 deleted from function.preg-replace by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-93288@lists.php.net to get a copy of this message | ||
Note Submitter: masterkumon at yahoo dot com
----
Example 1. Convert HTML to text just work in <b>valid </b> HTML tags.
You need little adjustion to process <b>invalid </b> HTML tags, such as unclosed tags.
simply add
<?
'@<[\/\!]*?[^<>]*?@si', // Strip out invalid HTML tags
?>
after the
<?
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
?>
and add ''(blank) on the related $replace array.
Your $search string should look like this :
<?
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<[\/\!]*?[^<>]*?@si', // Strip out invalid HTML
?>
WARNING: Put the invalid tags search string AFTER the valid tags search string.