Reputation: 21062
In order to get n-th character you can write:
mb_substr($s,$n,1);
but how to set n-th character?
Upvotes: -1
Views: 60
Reputation:
Like so:
$s = 'hello';
$n = 2; // first l
$r = 'x'; // replace with x
echo mb_substr($s, 0, $n) . $r . mb_substr($s, $n + 1);
Upvotes: 2