How to replace the characters in fixed positions in PHP?

后端 未结 7 1697
清歌不尽
清歌不尽 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:23

    $str="HelloWorld";
    print preg_replace("/^(....)....(.*)/","\\1****\\2",$str);
    

提交回复
热议问题