如何在csv中写入更改后的文件内容

时间:2019-03-27 21:28:29

标签: php curl

我有问题。我正在使用url下载csv文件并使用curl库,但是问题是,此csv文件不正确,因此我需要在逗号(,)上更改分号(;)。

if ($fileHandle) {
    $url = $this->csvUrl;
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_FILE, $fileHandle);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $string = fopen($localPath, 'r');
    $data = stream_get_contents($string, -1, 30);
    $data = str_replace(';', ',', $data);
    curl_exec(???);
    curl_close(???);
    chmod($localPath, 0755);

    return $localPath;
}

我想在此路径上写更改的内容。

0 个答案:

没有答案