代码:
<?php
/**
* @Author: TIM
* @Date: 2022-01-12 14:31:12
* @Email: 61468384@qq.com
* @Blog: http://www.tim-blog.com
* @Desc: 简单即是美 Simple is beautiful...
* @Last Modified by: 1
* @Last Modified time: 2022-01-12 21:45:00
*/
function clfh($content) {
$m_content = thfh($content);
while(strstr($m_content,'{dh}')) {
$luanma = qu_luanma();
$m_content = preg_replace('/{dh}/',$luanma .',',$m_content,1);
}
while(strstr($m_content,'{jh}')) {
$luanma = qu_luanma();
$m_content = preg_replace('/{jh}/',$luanma .'。',$m_content,1);
}
while(strstr($m_content,'{fh}')) {
$luanma = qu_luanma();
$m_content = preg_replace('/{fh}/',$luanma .';',$m_content,1);
}
while(strstr($m_content,'{duh}')) {
$luanma = qu_luanma();
$m_content = preg_replace('/{duh}/',$luanma .'、',$m_content,1);
}
while(strstr($m_content,'{gth}')) {
$luanma = qu_luanma();
$m_content = preg_replace('/{gth}/',$luanma .'!',$m_content,1);
}
while(strstr($m_content,'{mh}')) {
$luanma = qu_luanma();
$m_content = preg_replace('/{mh}/',$luanma .':',$m_content,1);
}
return $m_content;
}
function qu_luanma() {
$luanma_array = array('','','','');
$luanma = '';
for ($i=0;$i<mt_rand(2,5);$i++) {
$luanma .= $luanma_array[mt_rand(0,count($luanma_array)-1)];
}
return $luanma;
}
function thfh($content) {
$content = preg_replace('/,/','{dh}',$content);
$content = preg_replace('/。/','{jh}',$content);
$content = preg_replace('/;/','{fh}',$content);
$content = preg_replace('/、/','{duh}',$content);
$content = preg_replace('/!/','{gth}',$content);
$content = preg_replace('/:/','{mh}',$content);
return $content;
}
说明:前台页面就不展示了 。前面有类似的案例