Home > Backend Development > PHP Problem > How to remove double quotes when reading csv file in php

How to remove double quotes when reading csv file in php

Release: 2023-02-28 10:06:01
Original
4330 people have browsed it

How to remove double quotes when reading csv file in php

1. When writing a CSV file, you need to first determine whether there are commas and double quotes and handle them accordingly. The code is as follows

How to remove double quotes when reading csv file in php

2. Implement the method code for processing when reading a csv file

How to remove double quotes when reading csv file in phpAfter reading the csv file, use the str_replace() function to replace the double quotes in the file.

str_replace() function replaces some characters in a string with other characters (case sensitive).

Example:

<?php
$arr = array("blue","red","green","yellow");
print_r(str_replace("red","pink",$arr,$i));
echo "替换数:$i";
?>
Copy after login

The effect is as follows:

How to remove double quotes when reading csv file in php

##Recommendation:

php server

The above is the detailed content of How to remove double quotes when reading csv file in php. 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