让我很困惑!这是代码。我得到 1 for $mc 那是一个计数器!并且在我设置 3 次后不能从 foreach 循环中中断。
代码:
$mc=0;
if(preg_match_all('/(\@\`)([^`]*)(`\:)/i', $txt, $matches)) {
foreach(@$matches[2] as $m) {
$mc++;
if($mc>3)
break;
$txt = str_replace("@`".$m."`:",'<a href="profile-'.$m.'">'.$m.'</a>:',$txt);
}
}
示例文本:
@`test`: test1234 @`test`: test1234 @`test`: test1234 @`test`: test1234 @`test`: test1234 @`test`: test1234 @`test`: test1234 @`test`: test1234 @`test`: test1234 @`test`: test1234 @`test`: test1234