note 56237 added to function.htmlentities
| From: | greenthumbat4point-webdesigndotde at osu1 dot php dot net | Date: | Sun, 28 Aug 2005 13:42:19 +0000 |
| Subject: | note 56237 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94291@lists.php.net to get a copy of this message | ||
if you need to htmlentity only the text-parts of a given html-string use the following function, in
the array put the attributes you want to be also html-ized
<?
function htmlenc($res) {
$res=preg_replace('#&[^ ;]+;#i','<\\0>',$res);
foreach(array('title','alt') as $k)
$res=preg_replace('#<([^<]*)
'.$k.'="([^"]*)"([^>]*)>#Uise', '"<\\1
'.$k.'=\"".htmlentities("\\2")."\"\\3>"',$res);
$res=preg_replace('#(^|>)([^<>]+)($|<)#Uise',
'"\\1".htmlentities("\\2")."\\3"',$res);
$res=preg_replace('#<(&[^ ;]+;)>#i','\\1',$res);
return $res;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56237
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56237&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56237&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56237&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56237&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56237&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56237&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56237&report=yes
Search -- http://master.php.net/manage/user-notes.php