Home > Article > Backend Development > Example of replacing asterisks in the middle of php mobile phone number_PHP tutorial
Today, the editor will introduce to you how to use the preg_replace function to replace the specified numbers in the middle of the mobile phone number with asterisks. This is used on many websites. Everyone will do this, let me introduce the example method below.
Regular expression method
1. The string contains multiple mobile phone numbers
The code is as follows
|
Copy code
|
||||||||||||||
$s=preg_replace('#(d{3})d{5}(d{3})#', '${1}*****${2}', $s); echo $s;
?>
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 Previous article:Common keywords such as PHP object-oriented development_PHP tutorialNext article:Common keywords such as PHP object-oriented development_PHP tutorial Related articlesSee more |