note 21016 added to function.preg-split
| From: | xan at ai002 dot de dot nospam | Date: | Thu, 25 Apr 2002 12:35:15 +0000 |
| Subject: | note 21016 added to function.preg-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29832@lists.php.net to get a copy of this message | ||
replace some text with its html chars except html-tags.
<?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<br>
<a href="http://www.google.de">göögle</a>
döh! ;>';
echo make_my_htmlchars($string);
?>
--
http://www.php.net/manual/en/function.preg-split.php
http://master.php.net/manage/user-notes.php?action=edit+21016
http://master.php.net/manage/user-notes.php?action=delete+21016
http://master.php.net/manage/user-notes.php?action=reject+21016