Home >Backend Development >PHP Tutorial > php 部分字符隐藏变* 的字符串替换有关问题

php 部分字符隐藏变* 的字符串替换有关问题

WBOY
WBOYOriginal
2016-06-13 13:14:351164browse

php 部分字符隐藏变* 的字符串替换问题
我举个例子,比如说:$str = "13760721151"; 

我要把这个手机号变成: 1376****1151 ;

就隐藏中间的大约三分之一的内容

怎么用PHP实现。感激不尽。。。。


------解决方案--------------------

PHP code

<?php $str = "13760721151"; 
echo substr_replace($str,"***",4,3);
?>
<br><font color="#e78608">------解决方案--------------------</font><br>
PHP code
内置函数没有
$str = "13760721151";  
//1376****1151
echo substr($str, 0, 4).'****'.substr($str, strlen($str) - 4); <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn