使用 PHP 删除字符串的前 4 个字符

发布于 2024-10-04 04:52:21 字数 30 浏览 0 评论 0 原文

如何使用 PHP 删除字符串的前 4 个字符?

How can I remove the first 4 characters of a string using PHP?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

も星光 2024-10-11 04:52:21

您可以使用 substr 函数返回子字符串从第5个字符开始:

$str = "The quick brown fox jumps over the lazy dog."
$str2 = substr($str, 4); // "quick brown fox jumps over the lazy dog."

You could use the substr function to return a substring starting from the 5th character:

$str = "The quick brown fox jumps over the lazy dog."
$str2 = substr($str, 4); // "quick brown fox jumps over the lazy dog."
命硬 2024-10-11 04:52:21

如果您使用的是多字节字符编码,并且不想像 substr 那样只删除前四个字节,请使用多字节对应的 mb_substr。这当然也适用于单字节字符串。

If you’re using a multi-byte character encoding and do not just want to remove the first four bytes like substr does, use the multi-byte counterpart mb_substr. This does of course will also work with single-byte strings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文