Substr_replace () Function: Hide the middle 4 digits of the phone number as the * number

Source: Internet
Author: User

<? PHP $mobile = "15810320826"echosubstr_replace($mobile, ' * * * ', 3, 4  ?>

Substr_replace

(PHP 4, PHP 5)

substr_replace- a substring of a replacement string

Descriptionmixed substr_replace ( mixed $string , mixed $replacement , mixed $start [, mixed $length ])

Substr_replace () is substituted in a copy of the string by using a substring that is qualified with the string start optional length parameter replacement .

Parameters

string

The input string.

An array of strings can is provided, in which case the replacements would occur on each string in turn. In this case, replacement the, start and length parameters may provided either as scalar values to is applied to each input str ing in turn, or as arrays, in which case the corresponding array element would be a used for each input string.

replacement

The replacement string.

start

If start positive, the replacement will string start at the start position.

If start it is negative, the substitution string starts at the penultimate start position.

length

If this parameter is set and is positive, the string length of the substring being replaced is indicated. If set to negative, it represents the number of characters at the end of the substring to be replaced string . If this parameter is not provided, it defaults to Strlen ( string ) (the length of the string). Of course, if it length is 0, then the function is where it will be replacement inserted string start .

return value

Returns the result string. If string It is a group, an array will also be returned.

Substr_replace () Function: Hide the middle 4 digits of the phone number as the * number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.