Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在特定点将文本插入 PHP 字符串而不覆盖任何内容?
使用长度值为 0 的 substr_replace()。
代码:
substr_replace("abcdefgh","-bbbb-",3,0);
上面的输出将是“abc-bbbb-defgh”
简单,使用substr():
substr()
$str_a = "foo bar"; $str_b = substr($str_a, 0, 3) . ' baz' . substr($str_a, 3);