note 35280 deleted from function.htmlentities by vincent
| From: | vincent@php.net | Date: | Tue, 26 Aug 2003 14:06:17 +0000 |
| Subject: | note 35280 deleted from function.htmlentities by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-55104@lists.php.net to get a copy of this message | ||
Note Submitter: Jens@ruhronline.de
----
mirrorball_girl at yahoo dot com has some errors in his function. here is the corrected version:
function superhtmlentities($text) {
$entities = array(128 => 'euro', 130 => 'sbquo', 131 =>
'fnof', 132 => 'bdquo', 133 => 'hellip', 134 =>
'dagger', 135 => 'Dagger', 136 => 'circ', 137 =>
'permil', 138 => 'Scaron', 139 => 'lsaquo', 140 =>
'OElig', 145 => 'lsquo', 146 => 'rsquo', 147 =>
'ldquo', 148 => 'rdquo', 149 => 'bull', 150 =>
'#45', 151 => 'mdash', 152 => 'tilde', 153 =>
'trade', 154 => 'scaron', 155 => 'rsaquo', 156 =>
'oelig', 159 => 'Yuml');
$new_text = '';
for($i = 0; $i < strlen($text); $i++) {
$num = ord($text{$i});
if (array_key_exists($num, $entities)) {
switch ($num) {
case 150: // Gedankenstrich
$new_text .= '-';
break;
default:
$new_text .= '&'.$entities[$num].';';
}
}
else
if($num < 127 || $num > 159) {
$new_text .= htmlentities($text{$i});
}
}
return $new_text;
}