duanming0494 2019-07-17 10:38
浏览 592

PHP不断向csv文件多次添加数据

Im trying to add data to a csv file, however every time i run the php script it will add the data two or three times and that is of course super annoying! Just wondering if anyone has an idea of why this is happening? PHP Code:

$my_file2 = 'TEMP/temp.csv';
$handle = fopen($my_file2, 'a');
$data = "Mobile,".$mobi.",Message,".$message."
";
fwrite($handle, $data);
fclose($my_file2);

An example of the csv file with double entry: enter image description here

</div>
  • 写回答

1条回答

  • duanfoumi5620 2019-07-17 10:46
    关注

    Have you tried to use fputcsv function?

    fputcsv ( resource $handle , array $fields [, string $delimiter = "," [, string $enclosure = '"' [, string $escape_char = "\\" ]]] ) : int
    
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料