Get the App
SLTechnology News&Howtos  ›  Development  › 

How to remove double quotation marks from a string by php

Shulou Source: shulou.com Published: 2022-06-01 18:28:54 09月18日 Update

Most people do not understand the knowledge points of this article "php how to regularly remove double quotes from strings", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "php how to regularly remove strings in double quotes" article.

In PHP, you can use the "preg_replace" function and "/ (\") / "regular expression to remove double quotes from a string, which is used to perform the search and replacement of a regular expression with the syntax of" preg_replace ('/ (\ ") /',', string)".

Operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer

How to remove double quotation marks from a string by php

The preg_replace function performs the search and replacement of a regular expression.

Grammar

Mixed preg_replace (mixed $pattern, mixed $replacement, mixed $subject [, int $limit =-1 [, int & $count]])

Search for parts of subject that match pattern and replace them with replacement.

Parameter description:

Pattern: the pattern to search for, which can be a string or an array of strings.

Replacement: the string or array of strings used for replacement.

Subject: the target string or array of strings to search for replacement.

$limit: optionally, the maximum number of replaceable times per subject string for each pattern. The default is-1 (unlimited).

$count: optional, the number of times the replacement is executed.

Return value

If subject is an array, preg_replace () returns an array and in other cases a string.

If the match is found, the replaced subject is returned, and in other cases, the unchanged subject is returned. If an error occurs, return NULL.

First of all, we need to write the reg='/ that matches the double quotation marks. You must understand that the double quotation marks are a special character, and the special characters need to be escaped according to the regular rules, so we get the regular $quotation (\ ") /'.

Examples are as follows:

Output result:

The above is about the content of this article on "how to regularly remove double quotes from a string by php". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Character string regular quotation mark content array search function expression special case article pattern times knowledge article grammar maximum value parameter Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Information Microsoft Redmi Docker