How to replace the characters in fixed positions in PHP?

后端 未结 7 1722
清歌不尽
清歌不尽 2020-12-11 07:43

I want to replace with the 4~8 characters of a string with *,how to do it?

HelloWorld

=>

Hell****ld
7条回答
  •  渐次进展
    2020-12-11 08:38

    You'll need to use substr_replace().

    $str = substr_replace("HelloWorld","****",3,-2);
    

提交回复
热议问题