This article to share the content of PHP is how to implement string substitution, has a certain reference value, the need for friends can refer to
Substr_replace (String,replacement,start,length)
The first argument is: the string to replace ( required )
The second argument is: Specify the string to replace ( required )
The third parameter is: Where to start the replacement ( required )
Positive number-begins the substitution at the specified position in the string
Negative number-replaces at the specified position from the end of the string
0-Start the substitution at the first character in the string
Fourth parameter: Specifies how many characters to replace ( optional )
Positive number-The length of the string being replaced
Negative-Indicates the number of characters at the end of the substring to be replaced.
0-Insert rather than replace
Cases:
$str = ' 220282198801011234 '; $new _str = Substr_replace ($str, ' ******** ', 6,8);p Rint_r ($new _str);
Print as follows:
220282******1234
Related recommendations:
An explanation of several string substitution functions in PHP
The first string in the PHP replacement string [Do not replace]
PHP: Commonly used string-related functions