复制代码 代码如下:
function strSplit($s, $len) {
$end = '…';
$result = '';
$strLen = strlen($s);
if ($strLen return $s;
}
$len -= 2;
for ($i=0; $i $c = $s[$i];
if (ord($c) $result .= $c;
} elseif ($i+1 $result .= $s[$i++] . $s[$i];
}
}
return ($i }
echo strSplit('1234567', 10), '
';
echo strSplit('1234567890', 10), '
';
echo strSplit('1234中文567890abcdefghijkl', 10), '
';
echo strSplit('全部都是中文', 10), '
';
echo strSplit('全a部b都c是d中e文', 10), '
';
输出:
1234567
1234567890
1234中文…
全部都是…
全a部b都…
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号