


PHP username, email, mobile phone account middle string to hide
<span>function </span><span>hideStar</span>(<span>$str</span>) { <span>//</span><span>用户名、邮箱、手机账号中间字符串以</span><span>*</span><span>隐藏 </span><span>if </span>(<span>strpos</span>(<span>$str</span><span>, </span><span>'@'</span>)) { <span>$email_array </span><span>= </span><span>explode</span>(<span>"@"</span><span>, </span><span>$str</span>)<span>; </span><span>$prevfix </span><span>= </span>(<span>strlen</span>(<span>$email_array</span><span>[</span><span>0</span><span>]</span>) <span>< </span><span>4</span>) <span>? </span><span>"" </span><span>: </span><span>substr</span>(<span>$str</span><span>, </span><span>0</span><span>, </span><span>3</span>)<span>; </span><span>//</span><span>邮箱前缀 </span><span>$count </span><span>= </span><span>0</span><span>; </span><span>$str </span><span>= </span><span>preg_replace</span>(<span>'/([\d\w+_-]{0,100})@/'</span><span>, </span><span>'***@'</span><span>, </span><span>$str</span><span>, </span><span>-</span><span>1</span><span>, </span><span>$count</span>)<span>; </span><span>$rs </span><span>= </span><span>$prevfix </span><span>. </span><span>$str</span><span>; </span>} <span>else </span>{ <span>$pattern </span><span>= </span><span>'/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i'</span><span>; </span><span>if </span>(<span>preg_match</span>(<span>$pattern</span><span>, </span><span>$str</span>)) { <span>$rs </span><span>= </span><span>preg_replace</span>(<span>$pattern</span><span>, </span><span>'$1****$2'</span><span>, </span><span>$str</span>)<span>; </span><span>// substr_replace($name,'****',3,4); </span>} <span>else </span>{ <span>$rs </span><span>= </span><span>substr</span>(<span>$str</span><span>, </span><span>0</span><span>, </span><span>3</span>) <span>. </span><span>"***" </span><span>. </span><span>substr</span>(<span>$str</span><span>, </span><span>-</span><span>1</span>)<span>; </span>} } <span>return </span><span>$rs</span><span>; </span>}
以上就介绍了PHP 用户名、邮箱、手机账号中间字符串以隐藏,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

MySQL is a commonly used relational database management system that provides a variety of functions to process and operate data. Among them, the REPLACE function is used to replace the specified part of the string. In this article, we will introduce how to use the REPLACE function for string replacement in MySQL and demonstrate its usage through code examples. First, let’s take a look at the syntax of the REPLACE function: REPLACE(str,search_str,replace_str).

What are the string search and replace techniques in Python? (Specific code example) In Python, strings are a common data type, and we often encounter string search and replace operations in daily programming. This article will introduce some common string search and replacement techniques, accompanied by specific code examples. To find a specific substring in a string, you can use the find() method or index() method of the string. The find() method returns the index of the first occurrence of the substring in the string.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

This article will explain in detail the ASCII value of the first character of the string returned by PHP. The editor thinks it is very practical, so I share it with you as a reference. I hope you can gain something after reading this article. PHP returns the ASCII value of the first character of a string Introduction In PHP, getting the ASCII value of the first character of a string is a common operation that involves basic knowledge of string processing and character encoding. ASCII values are used to represent the numeric value of characters in computer systems and are critical for character comparison, data transmission and storage. The process of getting the ASCII value of the first character of a string involves the following steps: Get String: Determine the string for which you want to get the ASCII value. It can be a variable or a string constant

This article will explain in detail how PHP returns the string from the start position to the end position of a string in another string. The editor thinks it is quite practical, so I share it with you as a reference. I hope you will finish reading this article. You can gain something from this article. Use the substr() function in PHP to extract substrings from a string. The substr() function can extract characters within a specified range from a string. The syntax is as follows: substr(string,start,length) where: string: the original string from which the substring is to be extracted. start: The index of the starting position of the substring (starting from 0). length (optional): The length of the substring. If not specified, then

Usage of Pattern.compile function in Java The Pattern.compile function in Java is a method used to compile regular expressions. Regular expression is a powerful string matching and processing tool that can be used to find, replace, verify strings and other operations. The Pattern.compile function allows us to compile a string pattern into a Pattern object, which can then be used to perform a series of string operations. Pattern.compi

The PatternSyntaxException class represents an unchecked exception thrown when a syntax error occurs in a regular expression string. This class contains three main methods namely - getDescription() - returns the description of the error. getIndex() - Returns the error index. getPattern() - Returns the regular expression pattern in which the error occurred. getMessage() - Returns the complete message containing the error, the index, the regular expression pattern in which the error occurred, and the error in the indicated pattern. Example Real-time demonstration importjava.util.Scanner;importjava.util.regex.Matcher;i

Understand the substr() function in PHP for intercepting strings. In the PHP language, the substr() function is a very useful string processing function, which can be used to intercept string fragments at a specified position and length. The substr() function accepts three parameters: the string to be intercepted, the starting position of the interception, and the length of the interception. Below we will introduce the use of the substr() function in detail and give specific code examples. Basic usage of substr() function substr() function
