Get the App
SLTechnology News&Howtos  ›  Development  › 

How Php replaces all specified characters

Shulou Source: shulou.com Published: 2022-06-03 10:52:44 11月15日 Update

This article mainly introduces how Php replaces all the specified characters. It is very detailed and has certain reference value. Friends who are interested must finish reading it.

Php replaces all the specified characters: 1, using the "str_replace (find,replace,string,count)" method; 2, through the "preg_replace ()" method.

This article operating environment: windows7 system, PHP7.1 version, Dell G3 computer.

Common functions are:

Str_replace () and preg_replace ().

The str_replace () function replaces other characters in the string with one string.

Str_replace (find,replace,string,count)

Parameters.

Find is required. Specifies the value to look for.

Replace is required. Specifies the value that replaces the value in find.

String is required. Specifies the string to be searched.

Count is optional. A variable that counts the number of substitutions.

Str_replace ("raykaeso", "leixuesong", "raykaeso love php"); preg_replace (pattern, replacement, subject,limit =-1, $count)

Function: to perform the search and replacement of a regular expression

Pattern is required. The pattern that needs to be searched.

Replacement is required. A string or array used to replace.

Subject is required. A string or array to replace.

The number of limit replacements. -1 is infinite

The number of times count completed the replacement, variable

The above is all the content of the article "how Php replaces all specified characters". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Characters strings methods search content functions variables arrays times articles values functions interests parameters guys buddies commonly used more patterns rules Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info macOS OPPO Reno Microsoft MySQL