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 164 views
1 answer 149 views
1 answer 160 views
1 answer 172 views
1 answer 100 views
2 answers 134 views
1 answer 116 views
...