Home>Article>Backend Development> How to remove double quotes from data obtained by php

How to remove double quotes from data obtained by php

青灯夜游
青灯夜游 Original
2022-04-27 14:58:18 2978browse

Removal method: 1. Use the "$str='obtained data';" statement to store the data as a string in a variable; 2. Use "str_replace('"',"",$str )" or "preg_replace('/\"/',"",$str)" statement can replace the double quotes of the string with empty characters.

How to remove double quotes from data obtained by php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Data obtained by php Method to remove double quotes

1. Store the obtained data as a string in a variable

$str='获取的数据';

2. Replace the double quotes of the string with empty characters

Method 1: Use the str_replace() function

"; $new = str_replace('"',"",$str); echo "新字符串:".$new; ?>

How to remove double quotes from data obtained by php

Method 2: Use the preg_replace() function With regular expressions/\"/

"; $new = preg_replace('/\"/',"",$str); echo "新字符串:".$new; ?>

How to remove double quotes from data obtained by php

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to remove double quotes from data obtained by php. 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