Per esempio, se in $str c'è il tuo testo, che contiene lettere accentate che vuoi trasformare in entità html:

codice:
$testoentita = preg_replace(array("à","è","ì","ò","ù","é"),array("&a grave","&e grave","&i grave","&o grave","&u grave","&e acute"), $str);
togliendo gli spazi nel secondo array