note 92104 deleted from function.htmlentities by cmb
| From: | cmb@php.net | Date: | Sun, 01 Dec 2019 08:32:13 +0000 |
| Subject: | note 92104 deleted from function.htmlentities by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213301@lists.php.net to get a copy of this message | ||
Note Submitter: brianhamner at yahoo dot com
----
If you want something simple that actually works, try this. Strips MS word and other entities and
returns a clear data string:
<?php
//call this function
function DoHTMLEntities ($string) {
$trans_tbl[chr(145)] = '‘';
$trans_tbl[chr(146)] = '’';
$trans_tbl[chr(147)] = '“';
$trans_tbl[chr(148)] = '”';
$trans_tbl[chr(142)] = 'é';
$trans_tbl[chr(150)] = '–';
$trans_tbl[chr(151)] = '—';
return strtr ($string, $trans_tbl);
}
//insert your string variable here
$foo = str_replace("\r\n\r\n","",htmlentities($your_string));
$foo2 = str_replace("\r\n"," ",$foo);
$foo3 = str_replace(" & ","&",$foo2);
echo DoHTMLEntities ($foo3);
?>