if(!function_exists('ys_desc')) { function ys_desc($str,$len=150) { $str=trim((string)$str); if($str==='') { return ''; } // 1) 整块去掉 script / style $str=preg_replace('#<(script|style)[^>]*>.*?#is',' ',$str); // 2) 去掉所有 HTML 标签 $str=strip_tags($str); // 3) 去掉帝国分页等模板标记 $str=preg_replace('/\[!--[^\]]*--\]/',' ',$str); // 4) 常见实体还原(GBK 站点不能用 html_entity_decode,数字实体会按 UTF-8 处理变成乱码) $str=str_replace( array(' ',' ','“','”','‘','’','…','—','·','"',''','<','>','&'), array(' ',' ','“','”','‘','’','…','—','·','"',"'",'<','>','&'), $str ); // 5) 压缩换行与连续空格 $str=preg_replace('/[\r\n\t]+/',' ',$str); $str=preg_replace('/ {2,}/',' ',$str); $str=trim($str); if($str==='') { return ''; } // 6) 按“字”截断:GBK 双字节算 1 个字 $l=strlen($str); $i=0; $n=0; $out=''; while($i<$l) { if($n>=$len) { break; } $step=(ord($str[$i])>0x80)?2:1; $out.=substr($str,$i,$step); $i+=$step; $n++; } if($i<$l) { $out.='…'; } // 7) 转义为 HTML 属性值(GBK 下 htmlspecialchars 不支持 GBK,手工替换) return str_replace(array('"',"'",'<','>'),array('"',''','<','>'),$out); } } ?> 深夜思念专题列表 - 幼教网
会员,您有金币 0 个! 金币充值 浏览记录 退出登陆

热门下载

当前位置:首页 > TAG列表 > 深夜思念