function html2text($document){
$search = array(‘@<script[^>]*?>.*?</script>@si’, // Strip out javascript
‘@<[\/\!]*?[^<>]*?>@si’, // Strip out HTML tags
‘@<style[^>]*?>.*?</style>@siU’, // Strip style tags properly
‘@<![\s\S]*?–[ \t\n\r]*>@’ // Strip multi-line comments including CDATA
);
$text = preg_replace($search, ”, $document);
return $text;
}
function getrequired($iugl,$csn,$csen){
if ($csn!=”){
if (preg_match(“/$csn/”,$iugl)){
list($r,$iulast)=explode($csn,$iugl);
if ($csen!=”){
list($iulast,$r)=explode($csen,$iulast);
}
return trim($iulast);
}else {return “XX”;}
}else{
if ($csen!=”){
list($iulast)=explode($csen,$iugl);
return trim($iulast);
}else {return “XX”;}
}
}
Rohit,
Thanks for a very succinct script. Sometimes this type of information is not presented in a way that can be easily applied in real life. This is good stuff! I’ve now got two extra defenses against spam/attacks.
Thank You,
Tony Fantis
Comment by Tony Fantis — January 14, 2011 @ 11:54 pm |