标签: php string character
为了获得第n个角色,你可以写:
mb_substr($s,$n,1);
但如何设置第n个字符?
答案 0 :(得分:2)
像这样:
$s = 'hello'; $n = 2; // first l $r = 'x'; // replace with x echo mb_substr($s, 0, $n) . $r . mb_substr($s, $n + 1);