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

WBOY
Release: 2016-06-13 13:14:35
Original
1142 people have browsed it

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

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

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

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


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

PHP code

<?php $str = "13760721151"; 
echo substr_replace($str,"***",4,3);
?>
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
内置函数没有
$str = "13760721151";  
//1376****1151
echo substr($str, 0, 4).'****'.substr($str, strlen($str) - 4); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!