It will also convert some / / common HTML entities to their text equivalent. $search = array ("'script[^ ]*? .*? / script'si", / / Strip out javascript"' [\ /\ !]* ?[^ ]*? 'si", / / Strip out html tags "'([\r\n])[\s]+'", / / Strip out white space "'(quot_BAR_#34) ;'i", / / Replace html entities"' (amp_BAR_#38) ;'i", "'(lt_BAR_#60) ;'i","' (gt_BAR_#62) ;'i", "'(nbsp_BAR_#160) ;'i","' (iexcl_BAR_#161) ;'i", "'(cent_BAR_#162) ;'i","' (pound_BAR_#163) ;'i", "'(copy_BAR_#169) ;'i","' #(\d+) ;'e"); / / evaluate as php $replace = array ("", "", "\\1", "\"", "", "", "", "", chr(161), chr(162), chr(163), chr(169), "chr(\\1)"); $text = preg_replace ($search, $replace, $document);
Il remplace aussi quelques entités HTML / / courante en leur équivalent texte. $search = array ("'script[? ]*? .*? / script 'si", / / Supprime le javascript"' [\ /\ !]* ?[^? ]*? 'si", / / Supprime les balises HTML "'([\r\n])[\s]+'", / / Supprime les espaces "'(quot_BAR_#34) ;'i", / / Supprime les entites HTML"' (amp_BAR_#38) ;'i", "'(lt_BAR_#60) ;'i","' (gt_BAR_#62) ;'i", "'(nbsp_BAR_#160) ;'i","' (iexcl_BAR_#161) ;'i", "'(cent_BAR_#162) ;'i","' (pound_BAR_#163) ;'i", "'(copy_BAR_#169) ;'i","' #(\d+) ;'e"); / / Evaluation comme PHP $replace = array ("", "", "\\1", "\"", "", "",? "," ", chr(161), chr(162), chr(163), chr(169), "chr(\\1)"); $text = preg_replace ($search, $replace, $document);?