Php 将周期过长的实例替换为单个&;hellip;实体

Php 将周期过长的实例替换为单个&;hellip;实体,php,regex,replace,Php,Regex,Replace,我试图用PHP过滤公开提交的内容,以防止人们在内容末尾添加太多句点 提交的内容可能采用以下html格式: <p>Hi Jummy. I haz the lolz...............</p> <h3>Yeah.... <a href="/foo">dem lolz are funny</a>..</h3> 因此,上述示例将变成: <p>Hi Jummy. I haz the lolz&helli

我试图用PHP过滤公开提交的内容,以防止人们在内容末尾添加太多句点

提交的内容可能采用以下html格式:

<p>Hi Jummy. I haz the lolz...............</p>
<h3>Yeah.... <a href="/foo">dem lolz are funny</a>..</h3>
因此,上述示例将变成:

<p>Hi Jummy. I haz the lolz&hellip;</p>
<h3>Yeah&hellip; <a href="/foo">dem lolz are funny</a>.</h3>
你好,朱米。我是哈兹和哈利普

是的。
非常感谢

首先,替换三个或更多句点的所有实例

$content = preg_replace('/\.{3,}/', '&hellip;', $content);
然后,替换两个句点的实例

$content = str_replace('..', '.', $content);
$content = str_replace('..', '.', $content);