Ask questions about WordPress courses

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.

	function cleanTextHtml($text){
	$search = array ("']*?>.*?'si",  // Вырезается javascript 
					 "'<[\/\!]*?[^<>]*?>'si",           // Вырезаются html-тэги 
					 "'([\rn])[\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;
	}

 


Купить хостинг WordPress
WordPress tutor
Online tutoring services. List of courses I teach
  • Basic web design course;
  • Site layout;
  • General course on CMS WordPress and continuation of the course on template development;
  • Website development in PHP.
Read more on the page WordPress tutor
*/

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal