duanming0494 2018-07-14 02:22
浏览 32

ftruncate php csv阻止LF被删除

i write an array to csv file using fputcsv in php . i know that fputcsv writes a empty line as the last out put so my csv looks like

  1. apples
  2. orranges
  3. pear
  4. empty last line

What i did to remove the last empty line was use the below code and it works it writes a csv without the last empty line.

    $stat = fstat($handle);
    ftruncate($handle, $stat['size']-1);

My problem is that it delets the LF code and what than means on the next time i append to my csv a new value just gets appended to the same line as line 3 in stead of next line because the LF is missing ...

  1. apples LF
  2. orranges LF
  3. pear

anyone know how to fix the above ?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
    • ¥88 实在没有想法,需要个思路
    • ¥15 MATLAB报错输入参数太多
    • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
    • ¥15 有赏,i卡绘世画不出
    • ¥15 如何用stata画出文献中常见的安慰剂检验图
    • ¥15 c语言链表结构体数据插入
    • ¥40 使用MATLAB解答线性代数问题
    • ¥15 COCOS的问题COCOS的问题
    • ¥15 FPGA-SRIO初始化失败