Home  >  Article  >  Backend Development  >  How to replace php with Chinese double quotes

How to replace php with Chinese double quotes

coldplay.xixi
coldplay.xixiOriginal
2020-07-29 16:02:372910browse

How to replace php with Chinese double quotes: use the [preg_replace] function method, [${1}] uses the first reference in the first parameter, and the second parameter means to replace the first The content within English double quotes matched by a parameter's regular expression is placed in Chinese double quotes.

How to replace php with Chinese double quotes

How to replace php with Chinese double quotes:

$a = '我"你';
echo $a,"<br/>";
$a = preg_replace("\"","\“",$a);
echo $a;

Regularity of the first parameter of preg_replace, No. The second parameter is the replacement result, and the third parameter is the string to be replaced.

The first parameter'/"([^"]*)"/' means matching double quotation marks appearing in pairs, () represents Quotation, [^"]* represents the content within the quotation marks, which is a string of any length that does not contain ".

The second parameter'"${1 }"'${1} uses the first reference in the first parameter, which is the content within double quotes, so the second parameter means to replace the first The content within the English double quotes matched by the regular expression of each parameter is placed in the Chinese double quotes.

Related learning recommendations:

PHP programming from entry to proficiency

The above is the detailed content of How to replace php with Chinese double quotes. For more information, please follow other related articles on the PHP Chinese website!

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