如何在特定位置插入字符串中的字符?
How to insert character in a string at a specific position?
$str="Hello From Other Side ";
$add = rand(20,50);
如何在字符串中特定位置的每个字符后插入一个数字或字符作为 (25)
?
结果
He25llo Fr25om Ot26her S25ide
谢谢
您可以使用substr()
功能!
如果你想在 $str="Hello From Other Side ";
的位置 2!
中插入 25
你能做到
$pos=2;
$new_string= substr($str, 0, $pos). "25" . substr($str, $pos);
结果将是:
"He25llo From Other Side "
$str="Hello From Other Side ";
$add = rand(20,50);
如何在字符串中特定位置的每个字符后插入一个数字或字符作为 (25)
?
结果
He25llo Fr25om Ot26her S25ide
谢谢
您可以使用substr()
功能!
如果你想在 $str="Hello From Other Side ";
的位置 2!
25
你能做到
$pos=2;
$new_string= substr($str, 0, $pos). "25" . substr($str, $pos);
结果将是:
"He25llo From Other Side "