Segnalo questa utile funzione che ho trovato sul manuale, grazie al link di daniele_dll:
http://www.php.net/htmlentities
[php]
<?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_strin g));
$foo2 = str_replace("\r\n"," ",$foo);
$foo3 = str_replace(" & ","&",$foo2);
echo DoHTMLEntities ($foo3);
?>
[php]
![]()