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
2. Implement the method code for processing when reading a csv file
After 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"; ?>
The effect is as follows:
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!