精華 帝國PHP系統(tǒng)CMS用strlen()函數(shù)統(tǒng)計文章內(nèi)容newtext的字數(shù)
<p>首先php中統(tǒng)計函數(shù)是:strlen()</p>
在帝國php系統(tǒng)內(nèi)容頁中調(diào)用當(dāng)前文章的PHP代碼是:$navinfor[newstext]
統(tǒng)計的方法是:<?=strlen($navinfor[newstext])?>,這個是整個字段當(dāng)中字數(shù)的統(tǒng)計包括了字符,空格,html標(biāo)簽等。
過濾掉空格等字符的代碼:
<?=strlen(htmlspecialchars(strip_tags(str_replace(' ','',str_replace('“','',str_replace('”','',$navinfor[newstext]))))))?> 過濾掉html代碼,空格代碼等:
<?=strlen(htmlspecialchars(strip_tags(str_replace(' ','',str_replace('“','',str_replace('”','',str_replace(egetzy('rn'),'',str_replace(egetzy('<br />'),'',$navinfor[newstext]))))))))?>