How to replace the first N characters in a string in PHP

1 Answer

0 votes
$str = "pro php";

$N = 3;

$str = "XYZ" . substr($str, $N);

echo $str;




/*
run:

XYZ php

*/

 



answered Jun 12, 2022 by avibootz

Related questions

1 answer 280 views
1 answer 240 views
1 answer 257 views
1 answer 278 views
1 answer 202 views
2 answers 264 views
1 answer 209 views
...