Location: PHPKode > projects > Esvon Personals > esvon-personals/inc/funcs/word_html_cleanup.php
<?php

function word_html_cleanup($htm, $delstyles=false) {

$commoncrap = array('&quot;',
  'font-weight: normal;',
  'font-style: normal;',
  'line-height: normal;',
  'font-size-adjust: none;',
  'font-stretch: normal;',
);
 
$replace = array("'");

$htm = str_replace($commoncrap, $replace, $htm);
$pat = array();
$rep = array();
$pat[0] = '/(<table\s.*)(width=)(\d+%)(\D)/i';
$pat[1] = '/(<td\s.*)(width=)(\d+%)(\D)/i';
$pat[2] = '/(<th\s.*)(width=)(\d+%)(\D)/i';
$pat[3] = '/<td( colspan="[0-9]+")?( rowspan="[0-9]+")?
( width="[0-9]+")?( height="[0-9]+")?.*?>/i';
$pat[4] = '/<tr.*?>/i';
$pat[5]=
'/<\/st1:address>(<\/st1:\w*>)?
<\/p>[\n\r\s]*<p[\s\w="\']*>/i';
$pat[6] = '/<o:p.*?>/i';
$pat[7] = '/<\/o:p>/i';
$pat[8] = '/<o:SmartTagType[^>]*>/i';
$pat[9] = '/<st1:[\w\s"=]*>/i';
$pat[10] = '/<\/st1:\w*>/i';
$pat[11] = '/<p class="MsoNormal"[^>]*>(.*?)<\/p>/i';
$pat[12] = '/ style="margin-top: 0cm;"/i';
$pat[13] = '/<(\w[^>]*) class=([^ |>]*)([^>]*)/i';
$pat[14] = '/<ul(.*?)>/i';
$pat[15] = '/<ol(.*?)>/i';
$pat[17] = '/<br \/>&nbsp;<br \/>/i';
$pat[18] = '/&nbsp;<br \/>/i';
$pat[19] = '/<!-.*?>/';
$pat[20] = '/\s*style=(""|\'\')/';
$pat[21] = '/ style=[\'"]tab-interval:[^\'"]*[\'"]/i';
$pat[22] = '/behavior:[^;\'"]*;*(\n|\r)*/i';
$pat[23] = '/mso-[^:]*:"[^"]*";/i';
$pat[24] = '/mso-[^;\'"]*;*(\n|\r)*/i';
$pat[25] = '/\s*font-family:[^;"]*;?/i';
$pat[26] = '/margin[^"\';]*;?/i';
$pat[27] = '/text-indent[^"\';]*;?/i';
$pat[28] = '/tab-stops:[^\'";]*;?/i';
$pat[29] = '/border-color: *([^;\'"]*)/i';
$pat[30] = '/border-collapse: *([^;\'"]*)/i';
$pat[31] = '/page-break-before: *([^;\'"]*)/i';
$pat[32] = '/font-variant: *([^;\'"]*)/i';
$pat[33] = '/<span [^>]*><br \/><\/span><br \/>/i';
$pat[34] = '/" "/';
$pat[35] = '/[\t\r\n]/';
$pat[36] = '/\s\s/s';
$pat[37] = '/ style=""/';
$pat[38] = '/<span>(.*?)<\/span>/i';
//empty (no attribs) spans
$pat[39] = '/<span>(.*?)<\/span>/i';
//twice, nested spans
$pat[40] = '/(;\s|\s;)/';
$pat[41] = '/;;/';
$pat[42] = '/";/';
$pat[43] = '/<li(.*?)>/i';
$pat[44] = 
'/(<\/b><b>|<\/i><i>|<\/em><em>|
<\/u><u>|<\/strong><strong>)/i';
$rep[0] = '$1$2"$3"$4';
$rep[1] = '$1$2"$3"$4';
$rep[2] = '$1$2"$3"$4';
$rep[3] = '<td$1$2$3$4>';
$rep[4] = '<tr>';
$rep[5] = '<br />';
$rep[6] = '';
$rep[7] = '<br />';
$rep[8] = '';
$rep[9] = '';
$rep[10] = '';
$rep[11] = '$1<br />';
$rep[12] = '';
$rep[13] = '<$1$3';
$rep[14] = '<ul>';
$rep[15] = '<ol>';
$rep[17] = '<br />';
$rep[18] = '<br />';
$rep[19] = '';
$rep[20] = '';
$rep[21] = '';
$rep[22] = '';
$rep[23] = '';
$rep[24] = '';
$rep[25] = '';
$rep[26] = '';
$rep[27] = '';
$rep[28] = '';
$rep[29] = '';
$rep[30] = '';
$rep[31] = '';
$rep[32] = '';
$rep[33] = '<br />';
$rep[34] = '""';
$rep[35] = '';
$rep[36] = '';
$rep[37] = '';
$rep[38] = '$1';
$rep[39] = '$1';
$rep[40] = ';';
$rep[41] = ';';
$rep[42] = '"';
$rep[43] = '<li>';
$rep[44] = '';
if($delstyles===true){
  $pat[50] = '/ style=".*?"/';
  $rep[50] = '';
}
ksort($pat);
ksort($rep);
return preg_replace($pat,$rep,$htm);

}

?>
Return current item: Esvon Personals