Cleaning up code from HTML, JavaScript and White Space
Compiled a script from different parts of the code, found on the internet, for yourself when counting the number of words in the text. There were some good scripts, but now I don't remember where they are.
Write about your scripts, send yours and if you want, I will make a review for you, or you can write it yourself, and i will check. Good luck with development.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
function cleanTextHtml($text){ $search = array ("'<script[^>]*?>.*?</script>'si", // Вырезается javascript "'<[\/\!]*?[^<>]*?>'si", // Вырезаются html-тэги "'([\r\n])[\s]+'", // Вырезается пустое пространство "'&(quot|#34);'i", // Замещаются html-элементы "'&(amp|#38);'i", "'&(lt|#60);'i", "'&(gt|#62);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i" ); $replace = array ("", "", "\\1", "\"", "&", "<", ">", " ", chr(161), chr(162), chr(163), chr(169) ); $text = preg_replace($search, $replace, $text); return $text; } |
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.