substr_replace()函数:将手机号中间4位隐藏为*号
2015-05-13 18:48
316 查看
<?php $mobile = "15810320826"; echo substr_replace($mobile,'****',3 , 4); ?>
substr_replace
(PHP 4, PHP 5)substr_replace — 替换字符串的子串
说明
mixed substr_replace ( mixed$string, mixed
$replacement, mixed
$start[, mixed
$length] )
substr_replace() 在字符串
string的副本中将由
start和可选的
length参数限定的子字符串使用
replacement进行替换。
参数
string
输入字符串。
An array of strings can be provided, in which case the replacements will occur on each string in turn. In this case, the
replacement,
startand
lengthparameters may be provided either as scalar values to be applied to each input string in turn, or as arrays, in which case the corresponding array element will be used for each input string.
replacement
替换字符串。
start
如果
start为正数,替换将从
string的
start位置开始。
如果
start为负数,替换将从
string的倒数第
start个位置开始。
length
如果设定了这个参数并且为正数,表示
string中被替换的子字符串的长度。如果设定为负数,它表示待替换的子字符串结尾处距离
string末端的字符个数。如果没有提供此参数,那么它默认为 strlen(
string) (字符串的长度)。当然,如果
length为 0,那么这个函数的功能为将
replacement插入到
string的
start位置处。
返回值
返回结果字符串。如果string是个数组,那么也将返回一个数组。
相关文章推荐
- 隐藏手机号中间4位算法,替换手机号中间四位为*
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- 正则表达式隐藏手机号中间4位数字
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java—正则表达式隐藏手机号中间4位
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- 正则隐藏手机号中间4位
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil
- Java隐藏银行卡号或者手机号中间几位,用*号代替工具类实现HideDataUtil