How to replace php with Chinese double quotes

coldplay.xixi
Release: 2023-03-03 13:54:02
Original
2910 people have browsed it

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;
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template