$string = utf8_decode('foáo = "holááááooo don";');$string = preg_replace_callback('/(["\'])(.*?)\1/', create_function('$e', "return \$e[1].htmlentities(\$e[2]).\$e[1];"), $string);echo $string;