PHP function to replace a (i)th-position character

前端 未结 5 1716
梦如初夏
梦如初夏 2020-12-03 10:20

Is there a function in PHP that takes in a string, a number (i), and a character (x), then replaces the character at position (i) with

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 10:31

    I amazed why no one remember about substr_replace()

    substr_replace($str, $x, $i, 1);
    

提交回复
热议问题