Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $short_news = substr($short_news,0,100);
- /*Эта ф-я работает с кодировкой utf-8 , внимание.*/
- function close_tags($text_html){
- if (!trim($text_html)) return '';
- $get_string_between = function($string, $start, $end){
- $string = ' ' . $string;
- $ini = strpos($string, $start);
- if ($ini == 0) return $string;
- $ini += strlen($start);
- $len = strpos($string, $end, $ini) - $ini;
- return substr($string, $ini, $len);
- };
- $doc = new DOMDocument('1.0', 'UTF-8');
- libxml_use_internal_errors(true);
- $doc->loadHTML('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' .$text_html);
- $doc->encoding = 'utf-8';
- libxml_clear_errors();
- $text_html = $get_string_between(trim($doc->saveHTML()," rn" ), '<body>', '</body>');
- return $text_html;
- }
- $short_news = close_tags(mb_substr($news_full_text,0,300));
Add Comment
Please, Sign In to add comment