如何替换PHP中固定位置的字符? [英] How to replace the characters in fixed positions in PHP?
本文介绍了如何替换PHP中固定位置的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用*
替换为字符串的4~8
字符,怎么做?
I want to replace with the 4~8
characters of a string with *
,how to do it?
HelloWorld
=>
Hell****ld
推荐答案
使用
substr_replace()
喜欢
substr_replace($string, '****', 4 , 4);
了解更多:
http://php.net/manual/zh/function.substr- replace.php
这篇关于如何替换PHP中固定位置的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文