note 21015 deleted from function.preg-match-all by sniper
| From: | sniper@php.net | Date: | Tue, 30 Sep 2003 12:22:46 +0000 |
| Subject: | note 21015 deleted from function.preg-match-all by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57433@lists.php.net to get a copy of this message | ||
Note Submitter: mow²
----
My above expample's wrong ^^.
Here's a better 1 but also with some limitations..
<?php
function make_my_htmlchars($text)
{
$chars = preg_split('#(<\/?)(\w+)([^>]*>)#mis', $text, -1,
PREG_SPLIT_NO_EMPTY);
//print_r($chars);
for($i=0;$i<count($chars);$i++) {
$text=str_replace($chars[$i],htmlentities($chars[$i]),$text);
}
return(stripslashes($text));
}
$string='Iam just a lame <> string häving ßome lame german <b>chärs</b>
MÖH
döh! ;>';
echo make_my_htmlchars($string);
?>