note 37721 added to function.htmlentities

From: Date: Mon, 24 Nov 2003 11:53:26 +0000
Subject: note 37721 added to function.htmlentities
Groups: php.notes 
Request: Send a blank email to php-notes+get-60909@lists.php.net to get a copy of this message
A little function that may help someone. Is useful where, FE, someone writes a text through a content management panel and is also able to put html (bolds, italics,...), so we don't want to convert html tags but all the rest. The code offers a few examples of extra entities. function myhtmlentities($str) { $tbl=get_html_translation_table(HTML_ENTITIES); unset ($tbl["<"]); unset ($tbl[">"]); unset ($tbl["'"]); unset ($tbl['"']); $tbl["“"]="&quot;"; $tbl["”"]="&quot;"; $tbl["…"]="..."; $tbl["—"]="-"; $tbl["»"]="&raquo;"; $tbl["«"]="&laquo;"; return str_replace(array_keys($tbl),array_values($tbl),$str); } ---- Manual Page -- http://www.php.net/manual/en/function.htmlentities.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37721 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37721&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37721&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60909) next »