欢迎您光临自学哈网,只为分享网络知识教程,供大家学习参考!

「自学哈网」帝国获取简介代码格式去空格换行的解决方法

作者 : 自学哈 本文共1258个字,预计阅读时间需要4分钟 2022-11-26 共101人阅读
也想出现在这里? 联系我们

帝国获取简介代码格式去空格换行的解决方法

把如下的代码放入/e/class/userfun.php,然后在前台需要的地方调用即可。

functionformat_html($str){
$str=trim($str);
$str=str_replace('&','',$str);
$str=str_replace('ldquo;','',$str);
$str=str_replace('rdquo;','',$str);
$str=str_replace('middot;','·',$str);
$str=str_replace('lsquo;','‘',$str);
$str=str_replace('rsquo;','’',$str);
$str=str_replace('hellip;','…',$str);
$str=str_replace('mdash;','—',$str);
$str=str_replace('ensp;','',$str);
$str=str_replace('emsp;','',$str);
$str=str_replace('nbsp;','',$str);
$str=str_replace(' ','',$str);
$str=str_replace('t','',$str);
$str=str_replace('rn','',$str);
$str=str_replace('r','',$str);
$str=str_replace('n','',$str);
$str=str_replace('','',$str);
$str=str_replace('amp;','',$str);
$str=str_replace(PHP_EOL,'',$str);
$str=preg_replace('/s(?=s)/','',$str);//接着去掉两个空格以上的
$str=preg_replace('/[nrt]/','',$str);//最后将非空格替换为一个空格
returntrim($str);
}

本站声明:
本站所有资源来源于网络,分享目的仅供大家学习和交流!如若本站内容侵犯了原著者的合法权益,可联系邮箱976157886@qq.com进行删除。
自学哈专注于免费提供最新的分享知识、网络教程、网络技术的资源分享平台,好资源不私藏,大家一起分享!

自学哈网 » 「自学哈网」帝国获取简介代码格式去空格换行的解决方法
也想出现在这里? 联系我们
© 2022 Theme by - 自学哈网 & WordPress Theme. All rights reserved 浙ICP备2022016594号