Clean text of labels HTML

Acquittal labels, spaces, characters nonwished


It generates text without labels HTML, php, spaces, etc. clean Text for example to generate the description or the title in puts them labels to optimize the SEO.

/* TEST OF the FUNCTION * <meta description= " <? =text_description (€˜text with spaces, <div>etiquetas</div> or any generated code HTML€™)? > " >

/* FUNCTION TO CLEAN to TEXTS * function text_description ($text, $limit = 160) \ {$count = strlen ($text); $srch = Array (€˜/\ > [^ \ S] +/s€™, €˜/[^ \ S] + \ </s€™, €˜/(\ s) +/s€™); $rmpl = Array (€˜>€™, €˜<€™, €˜\ \ 1€™); $text = preg_replace ($srch, $rmpl, $text); $text = str_replace (€œ> <€, €œ><€, $text); $text = preg_replace (€œ# \ s \ {2,} #€,€ €œ, $text); $text = strip_tags (trim (html_entity_decode ($text, ENT_QUOTES, €˜UTF-8€™), €œ\ xc2 \ xa0€)); $text = preg_replace (€œ/[\ n \ r]/€, "", $text); $text = stripslashes ($text); $text = strip_tags ($text); #$text = mysql_real_escape_string ($text); $text = trim ($text); $text = substr ($text, 0, $limit); if ($count > $limit) \ {$index = strrpos ($text, €œ€œ); $text = substr ($text, 0, $index); $text. = €œ€¦€; } return $text; }