Home >Backend Development >PHP Tutorial > 一个很简单的字符串切分有关问题

一个很简单的字符串切分有关问题

WBOY
WBOYOriginal
2016-06-13 13:39:45918browse

一个很简单的字符串切分问题
job***@apple.com
chenghai***@qq.com

让@左边的四个字符替换为 “*”

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

PHP code


$str = 'tstkfeacbcs@ss.cds';
echo preg_replace('/.{4}@/', '****@', $str);

//tstkfea****@ss.cds <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