首页 > 移动平台 > 详细

substr_replace()函数:将手机号中间4位隐藏为*号

时间:2015-05-13 21:20:50      阅读:310      评论:0      收藏:0      [点我收藏+]
<?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,start and length parameters 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 是个数组,那么也将返回一个数组。

substr_replace()函数:将手机号中间4位隐藏为*号

原文:http://www.cnblogs.com/kenshinobiy/p/4501352.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!