note 28190 added to function.htmlentities

From: Date: Sun, 05 Jan 2003 11:43:06 +0000
Subject: note 28190 added to function.htmlentities
Groups: php.notes 
Request: Send a blank email to php-notes+get-41686@lists.php.net to get a copy of this message
This function converts all the evil (invalid) characters Microsoft Word could possibly use to HTML entities: 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 => 'ndash', 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)) { $new_text .= '&'.$entities[$num].';'; } elseif($num < 127 || $num > 159) { $new_text .= $text{$i}; } } return htmlentities($new_text); } -- http://www.php.net/manual/en/function.htmlentities.php http://master.php.net/manage/user-notes.php?action=edit+28190 http://master.php.net/manage/user-notes.php?action=delete+28190 http://master.php.net/manage/user-notes.php?action=reject+28190

« previous php.notes (#41686) next »