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

帝国获取简介代码格式去空格换行的解决方法把如下的代码放入/e/class/userfun.php,然后在前台需要的地方调用即可。function format_html($str){
$str=trim($str);
$str=str_

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

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

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

如下示例代码:

<p>function format_html($str){<br />$str=trim($str);<br />$str=str_replace(&#39;&amp;&#39;,&#39;&#39;,$str);<br />$str=str_replace(&#39;ldquo;&#39;,&#39;&#39;,$str);<br />$str=str_replace(&#39;rdquo;&#39;,&#39;&#39;,$str);<br />$str=str_replace(&#39;middot;&#39;,&#39;&middot;&#39;,$str);<br />$str=str_replace(&#39;lsquo;&#39;,&#39;&lsquo;&#39;,$str);<br />$str=str_replace(&#39;rsquo;&#39;,&#39;&rsquo;&#39;,$str);<br />$str=str_replace(&#39;hellip;&#39;,&#39;&hellip;&#39;,$str);<br />$str=str_replace(&#39;mdash;&#39;,&#39;&mdash;&#39;,$str);<br />$str=str_replace(&#39;ensp;&#39;,&#39;&#39;,$str);<br />$str=str_replace(&#39;emsp;&#39;,&#39;&#39;,$str);<br />$str=str_replace(&#39;nbsp;&#39;,&#39;&#39;,$str);<br />$str=str_replace(&#39; &#39;,&#39;&#39;,$str);<br />$str=str_replace(&#39;t&#39;,&#39;&#39;,$str); &nbsp;<br />$str=str_replace(&#39;rn&#39;,&#39;&#39;,$str); &nbsp;<br />$str=str_replace(&#39;r&#39;,&#39;&#39;,$str); &nbsp;<br />$str=str_replace(&#39;n&#39;,&#39;&#39;,$str); &nbsp;<br />$str=str_replace(&#39; &#39;,&#39;&#39;,$str);<br />$str=str_replace(&#39;amp;&#39;,&#39;&#39;,$str);<br />$str=str_replace(PHP_EOL,&#39;&#39;,$str); &nbsp;&nbsp;<br />$str=preg_replace(&#39;/s(?=s)/&#39;,&#39;&#39;, $str);// 接着去掉两个空格以上的<br />$str=preg_replace(&#39;/[nrt]/&#39;,&#39; &#39;, $str);// 最后将非空格替换为一个空格<br />return trim($str);<br />}</p>
分享到 :
相关推荐

发表评论

登录... 后才能评论

评论(3)

加入本站VIP会员订阅计划,海量资源免费下载查看

目前为止共有3位优秀的VIP会员加入!

立即加入VIP会员